Created
July 10, 2019 20:27
-
-
Save kungfoo/95e8b034bcd2297b5341711223e63460 to your computer and use it in GitHub Desktop.
Really cool sala actor sample
This file contains hidden or 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 SecurityPricingActor(exchange: Exchange, backOffice: BackOffice) extends Actor { | |
def receive = { | |
case GetPricingInfo(security: Security) => | |
val originalSender = sender | |
val bidAndAskFuture = Future { exchange.getBidAndAsk(security.id) } | |
val lastPriceFuture = Future { backOffice.getLastPrice(security.id) } | |
val response = for { | |
(bid, ask) = bidAndAskFuture | |
lastPrice = lastPriceFuture | |
} yield SecurityPricing(bid, ask, lastPrice) | |
response map (originalSender ! _) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment