Skip to content

Instantly share code, notes, and snippets.

@Horusiath
Last active March 13, 2018 11:25
Show Gist options
  • Save Horusiath/31027b41d7d979cde04e100cb012ee88 to your computer and use it in GitHub Desktop.
Save Horusiath/31027b41d7d979cde04e100cb012ee88 to your computer and use it in GitHub Desktop.
akka-typed Akkling API idea
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