Last active
August 29, 2015 14:06
-
-
Save thinktainer/47101e784c748117de32 to your computer and use it in GitHub Desktop.
an agent that dies
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
type EventPublisher (eventBus, logger) = | |
let agent eventBus (logger : ILoggingService) = | |
new Agent<EventAggregateMessage>( | |
fun inbox -> | |
let rec loop () = async { | |
let! message = inbox.Receive() | |
match message with | |
| EventAggregate aggregate -> | |
try | |
let playerId = aggregate.PlayerScope.PlayerId.ToString() | |
logger.logInfo playerId aggregate.CorrelationToken "sending to bus" | |
let message = AggregateMapper.toMessageContract aggregate | |
do! publish eventBus message | |
logger.logInfo playerId aggregate.CorrelationToken "handled message" | |
with | |
| _ as e -> | |
logger.logError e "" | |
return! loop () | |
| Die -> return () } | |
loop ()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment