This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val statsRoute = (path("stats") & get)(handleGetStats) | |
private def handleGetStats: Route = { ctx => | |
actorRefFactory.actorOf(GetStatsRequestActor.props(ctx, statsActor)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GetStatsRequestActor( | |
ctx: RequestContext, | |
statsActor: ActorRef)(implicit override val json4sFormats: Formats) | |
extends Actor | |
with Json4sSupport { | |
statsActor ! StatsActor.GetState | |
context.setReceiveTimeout(2.seconds) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class RollCount(rolledNumber: Int, rollsCount: Int) | |
case class StatsResponseData(rollsCounts: Seq[RollCount]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -d -p 5672:5672 -p 15672:15672 dockerfile/rabbitmq | |
sbt "project game" run | |
sbt "project webapp" run | |
sbt "project statistics" run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl http://127.0.0.1:8083/stats | |
// Output: | |
{"rollsCounts":[]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
▶ curl --silent http://127.0.0.1:8083/stats | python -m json.tool | |
{ | |
"rollsCounts": [ | |
{ | |
"rolledNumber": 2, | |
"rollsCount": 5 | |
}, | |
{ | |
"rolledNumber": 1, | |
"rollsCount": 5 |
OlderNewer