Module

Pinto.Supervisor

This module represents supervisor in OTP See also gen_supervisor in the OTP docs (https://erlang.org/doc/man/supervisor.html#)

#ChildShutdownTimeoutStrategy

data ChildShutdownTimeoutStrategy

This maps to brutal | infinity | { timeout, Milliseconds } as per the underlying supervisor API

Constructors

#ChildSpec

type ChildSpec childProcess = { childType :: ChildType, id :: String, restartStrategy :: RestartStrategy, shutdownStrategy :: ChildShutdownTimeoutStrategy, start :: Effect (StartLinkResult childProcess) }

The specification of a child process, this maps to ChildSpec in the underlying supervisor API with the difference that none of them are optional.

childProcess is the typed pid of the started process (commonly GenServer.ServerPid)

#ChildType

data ChildType

This maps to supervisor | worker as per the underlying supervisor API

Constructors

#ChildNotStartedReason

data ChildNotStartedReason childProcess

#StartChildResult

#ErlChildSpec

#Flags

type Flags = { intensity :: Int, period :: Seconds, strategy :: Strategy }

The flags for a supervision tree, mapping onto sup_flags from the underlying supervisor API

#RestartStrategy

data RestartStrategy

This maps to transient | permanent | temporary as per the underlying supervisor API

Constructors

#Strategy

data Strategy

The strategy employed by this supervision tree, this maps to one_for_all | one_for_one | rest_for_one in the underlying supervisor API

Note: simple_one_for_one is deliberately missing, see: Supervisor.SimpleOneForOne

Constructors

#SupervisorSpec

type SupervisorSpec = { childSpecs :: List ErlChildSpec, flags :: Flags }

A complete specification for a supervisor, see Result in the underlying supervisor API

#SupervisorPid

#SupervisorType

#DeleteChildResult

#spec

spec :: forall childProcess. HasPid childProcess => ChildSpec childProcess -> ErlChildSpec

#startChild

startChild :: forall childProcess. HasPid childProcess => SupervisorRef -> ChildSpec childProcess -> StartChildResult childProcess

Given a supervisor reference and a child specification start a new child within the context of that supervisor See also supervisor:start_child

#terminateChild

terminateChild :: SupervisorRef -> String -> Effect TerminateChildResult

Given a supervisor reference and a child id terminate that given child See also supervisor:terminate_child

#deleteChild

deleteChild :: SupervisorRef -> String -> Effect DeleteChildResult

Given a supervisor reference and a child id delete that given child See also supervisor:delete_child

#stop

stop :: SupervisorRef -> Effect Unit

A convenience mechanism to stop a supervisor using sys:terminate

#maybeChildStarted

maybeChildStarted :: forall childProcess. StartChildResult childProcess -> Maybe childProcess

Converts a StartChildResult into a Maybe returning Just if the child was started and Nothing otherwise

#maybeChildRunning

maybeChildRunning :: forall childProcess. StartChildResult childProcess -> Maybe childProcess

Converts a StartChildResult into a Maybe returning Just if the child was started and Just if the child was already running and Nothing otherwise

#crashIfChildNotStarted

crashIfChildNotStarted :: forall childProcess. StartChildResult childProcess -> childProcess

#crashIfChildNotRunning

crashIfChildNotRunning :: forall childProcess. StartChildResult childProcess -> childProcess

Modules