Guest User

Untitled

a guest
Jan 7th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. def process(m: ProcessBatch): Future[List[Any]] = processTimer {
  2. if (m.actions.isEmpty) {
  3. EmptyDone
  4. } else {
  5. implicit val t: Timeout = m.timeout
  6.  
  7. val f = for {
  8. tx ← Future {
  9. val GameCycleContext(gameCycleId, _, _) = GameCycleContext.requireContext(m.context)
  10. Tx(
  11. gameCycleId,
  12. m.actions,
  13. currentTime + m.timeout.toMillis,
  14. Tx.mkLocation(framework.cluster.selfUniqueAddress),
  15. SerializableContext(m.context)
  16. )
  17. }
  18. _ ← storage.persist(tx.key, tx)
  19. resp ← (self ? tx).mapTo[TxResponse]
  20. result ← (resp.txActor ? Transaction.Process).mapTo[List[Any]]
  21. confirmed ← resp.txActor ? Confirm
  22. } yield result
  23.  
  24. f onFailure {
  25. case e: Throwable ⇒
  26. log(level = logger.Error, message = s"Error while processing transaction: $e", ex = e, ctx = m.context)
  27. }
  28.  
  29. f
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment