Supervision
Processes
Describe a child that a supervisor starts and restarts.
Most of the time you do not build these by hand: Repo.supervised, Jobs.supervised, Socket.supervised, and Platform.supervised already return a ChildSpecification. Use worker when you have a custom () -> Result StartError (Started a) start function (for example wrapping [Actor.start]).
Supervision.worker
(\() ->
Actor.new 0
|> Actor.onMessage handle
|> Actor.start
)Then Supervisor.add that spec onto your tree.
Types
ChildSpecification
type ChildSpecification a = ChildSpecificationHow a supervisor starts and restarts a child.
Examples
Supervision.worker startFn : ChildSpecification aRestart
type Restart
= Permanent
| Transient
| TemporaryRestart intensity for a supervised child.
- Permanent: always restart - Transient: restart only on abnormal exit - Temporary: never restart
Examples
PermanentValues
worker
worker : (() -> Result StartError (Started a)) -> ChildSpecification aSupervise a child that starts from a zero-argument function.
Examples
Supervision.worker
(\() ->
Actor.new 0
|> Actor.onMessage handle
|> Actor.start
)