Skip to content

Instantly share code, notes, and snippets.

@LukasGasior1
Created July 27, 2015 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LukasGasior1/88b05f530bcad0069c60 to your computer and use it in GitHub Desktop.
Save LukasGasior1/88b05f530bcad0069c60 to your computer and use it in GitHub Desktop.
class GetStatsRequestActor(
ctx: RequestContext,
statsActor: ActorRef)(implicit override val json4sFormats: Formats)
extends Actor
with Json4sSupport {
statsActor ! StatsActor.GetState
context.setReceiveTimeout(2.seconds)
override def receive = {
case stats: Stats =>
val rollsCounts = stats.rollsCounts
.map(RollCount.tupled)
.toSeq
.sortBy(_.rollsCount)
.reverse
ctx.complete(StatsResponseData(rollsCounts))
context stop self
case ReceiveTimeout =>
ctx.complete(StatusCodes.RequestTimeout)
context stop self
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment