- Place Bet
- Show Bet's list
- Scala
- Akka Actors, Akka HTTP, Akka Persistence, Akka Cluster
- Cassandra
- Docker
The best way to run this webservice is to build and run docker image.
- Clone this repository
- Open terminal, navigate to the target folder
- Run:
sh ./runCluster.sh
- It will download necessary images of Cassandra and both, Game and Wallet, services
- Run them and bind to the local ports (Wallet service - localhost:8080, Game service - localhost:8081, localhost:8082)
-
Validate docker installation or install it (Download here)
-
Create docker network:
docker network create casino
-
Download Cassandra image using docker:
docker pull cassandra
-
Run cassandra container with alias name cassandra_db:
docker run --name cassandra_db -d --net casino cassandra:latest
-
Clone the repository for Wallet service:
git clone https://github.com/KRoLer/Casino-Wallet-Service.git
-
Navigate to the root folder
cd Casino-Wallet-Service
and run:sbt docker:publishLocal
-
Run newly created image:
docker run -p "8080:8080" -d --rm --name walletservice --net casino wallet-webservice:0.1
-
Clone this repository:
git clone https://github.com/KRoLer/Casino-Game-Service.git
-
Navigate to the root folder
cd Casino-Game-Service
and run:sbt docker:publishLocal
-
Run cluster with two instance:
docker run -p "8081:8081" -d -p "2551:2551" --rm --name gameservice --net casino game-webservice:0.1 -Dservice.withdraw.host=walletservice:8080 -Dakka.cluster.seed-host="gameservice" -Dakka.remote.netty.tcp.hostname="gameservice"
docker run -p "8082:8081" -d -p "2552:2552" --rm --name gameservice2 --net casino game-webservice:0.1 -Dservice.withdraw.host=walletservice:8080 -Dakka.remote.netty.tcp.port=2552 -Dakka.cluster.seed-host="gameservice" -Dakka.remote.netty.tcp.hostname="gameservice2"
-
To stop all containers use:
docker stop gameservice gameservice2 walletservice cassandra_db
To validate this service locally we recommend to use Postman. After installation open the collection link to import predefined basic calls.
cURL basic queries
- Place Bet Node 1 (Port: 8081)
curl --request POST \
--url http://localhost:8081/api/v1/bet \
--header 'Content-Type: application/json' \
--data '{
"playerId": 1,
"gameId": 1,
"amount": 10
}'
- Place Bet Node 2 (Port: 8082)
curl --request POST \
--url http://localhost:8082/api/v1/bet \
--header 'Content-Type: application/json' \
--data '{
"playerId": 1,
"gameId": 2,
"amount": 100
}'
- Get bets Node 1 (Port: 8081)
curl --request GET \
--url http://localhost:8081/api/v1/bets/1
- Get bets Node 2 (Port: 8082)
curl --request GET \
--url http://localhost:8082/api/v1/bets/1