Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. class SecurityPricingActor(exchange: Exchange, backOffice: BackOffice) extends Actor {
  2. def receive = {
  3. case GetPricingInfo(security: Security) =>
  4. val originalSender = sender
  5. val bidAndAskFuture = Future { exchange.getBidAndAsk(security.id) }
  6. val lastPriceFuture = Future { backOffice.getLastPrice(security.id) }
  7.  
  8. val response = for {
  9. (bid, ask) = bidAndAskFuture
  10. lastPrice = lastPriceFuture
  11. } yield SecurityPricing(bid, ask, lastPrice)
  12.  
  13. response map (originalSender ! _)
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement