Created
November 27, 2015 13:38
-
-
Save wiig-with-a-k/0008af99e131a6e8c260 to your computer and use it in GitHub Desktop.
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 Input = | |
| ResultGreat | |
| ResultNotSoGreat | |
type ResultImproverAgent (logger) = | |
let agent = MailboxProcessor.Start(fun inbox -> | |
let rec messageLoop () = async { | |
let! msg = inbox.Receive() | |
match msg with | |
| ResultGreat -> "Result already great, cannot be improved" |> logger | |
| ResultNotSoGreat -> "Result is not so great, putting it in the backlog" |> logger | |
return! messageLoop () | |
} | |
messageLoop () | |
) | |
member this.Post msg = agent.Post msg | |
type SomeAgent (logger, improveAgent) = | |
let agent = MailboxProcessor.Start(fun inbox -> | |
let rec messageLoop () = async { | |
let! msg = inbox.Receive() | |
match msg with | |
| ResultGreat -> "Nothin more todo, result is great!" |> logger | |
| ResultNotSoGreat -> "Result bad, sending it to be improved" |> logger | |
msg |> improveAgent | |
return! messageLoop () | |
} | |
messageLoop () | |
) | |
member this.Post msg = agent.Post msg | |
let Orchastrator () = | |
let log input = | |
input |> printfn "%s" | |
let improverAgent = ResultImproverAgent log | |
let someAgent = SomeAgent (log, improverAgent.Post) | |
ResultNotSoGreat |> someAgent.Post | |
0 | |
Orchastrator() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment