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 = ChildSpecification

How a supervisor starts and restarts a child.

Examples

Supervision.worker startFn : ChildSpecification a

Restart

type Restart
= Permanent
| Transient
| Temporary

Restart intensity for a supervised child.

- Permanent: always restart - Transient: restart only on abnormal exit - Temporary: never restart

Examples

Permanent

Values

worker

worker : (() -> Result StartError (Started a)) -> ChildSpecification a

Supervise a child that starts from a zero-argument function.

Examples

Supervision.worker
    (\() ->
        Actor.new 0
            |> Actor.onMessage handle
            |> Actor.start
    )