Supervision

Types (Actor.Types)

data Directive = Restart | Resume | Stop | Escalate | Propagate
data Decider   = Decider [(String, Directive)] Directive    -- a directive per kind, and a default
data Strategy  = OneForOne Decider | AllForOne Decider

Functions (Actor.Supervision)

Function Type Meaning
decider Directive -> Decider The same directive for every failure
onKind String -> Directive -> Decider -> Decider A directive for failures of a kind (the first rule wins)
byDefault Directive -> Decider -> Decider Replace the default
oneForOne Decider -> Strategy A failure touches the failed child alone
allForOne Decider -> Strategy A failure touches every child
restarting Strategy The default: one for one, restarting
decide Strategy -> Fault -> Directive The directive a strategy takes for a failure

Directives

Directive The child
Restart Starts over from its first state and methods; waiting messages stay
Resume Keeps its state and goes on
Stop Stops, its children first
Escalate Stays failed; the supervisor fails with the same fault
Propagate Goes on; the failure reached only the asker

Declaring

@supervision(oneForOne (onKind "Glitch" Resume (decider Restart)))   -- on a class
@B.withSupervision(strategy)                                         -- on a behaviour

Give a long strategy a name of its own (foremanStrategy :: Strategy) and put the name in the attribute.