Last active
March 13, 2018 11:25
-
-
Save Horusiath/31027b41d7d979cde04e100cb012ee88 to your computer and use it in GitHub Desktop.
akka-typed Akkling API idea
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 Command = Job of string | |
let active (count: int): Behavior<Command> = | |
Actor.behavior (fun ctx msg -> | |
match msg with | |
| Job payload -> | |
printfn "Received %s, current state: %d" payload count | |
// return updated state behavior, equivalent of become | |
active (count + 1)) | |
|> onSignal (fun ctx sig -> | |
// handler designed for system messages: lifecycle events, terminations, | |
match sig with | |
| PreStart -> printfn "Actor starting" | |
| PostStop -> printfn "Actor stopping" | |
Actor.same) // keep actor behavior unchanged | |
let ref: IActorRef<Command> = spawn system "my-actor" <| props(active 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment