capataz-0.1.0.1: OTP-like supervision trees in Haskell

Safe HaskellNone
LanguageHaskell2010

Control.Concurrent.Capataz.Internal.Supervisor

Synopsis

Documentation

forkSupervisor :: ParentSupervisorEnv -> SupervisorOptions -> Maybe (ProcessId, RestartCount) -> IO Supervisor Source #

Internal function that forks a supervisor thread; note this is different from the public forkSupervisor function which sends a message to the supervisor loop.

buildSupervisorEnv :: (CapatazEvent -> IO ()) -> (SupervisorMessage -> IO ()) -> STM SupervisorMessage -> SupervisorId -> SupervisorOptions -> IO SupervisorEnv Source #

Utility function that builds an utility record which is used on all internal APIs of the supervision logic.

handleMonitorEvent :: SupervisorEnv -> MonitorEvent -> IO Bool Source #

Handles an event produced by one of the processes this supervisor monitors.

handleControlAction :: SupervisorEnv -> ControlAction -> IO Bool Source #

Handles an action triggered by the public Capataz API.

haltSupervisor :: Text -> SupervisorEnv -> IO () Source #

Executes the shutdown operation of a Supervisor, including the termination of its supervised processes.

handleSupervisorMessage :: SupervisorEnv -> SupervisorMessage -> IO Bool Source #

Handles all messages that a Supervisor can receive from its monitored processes or from the public API.

supervisorLoop :: (forall b. IO b -> IO b) -> ParentSupervisorEnv -> SupervisorEnv -> RestartCount -> IO () Source #

This sub-routine executes the main thread loop of a Supervisor instance.

supervisorMain :: ParentSupervisorEnv -> SupervisorOptions -> SupervisorId -> RestartCount -> IO Supervisor Source #

This sub-routine starts a Supervisor thread and initializes its processList.

calcDiffSeconds :: UTCTime -> IO NominalDiffTime Source #

Tracks difference between two timestamps so that we keep track of a Supervisor error intensity.

calcRestartAction :: SupervisorEnv -> Int -> NominalDiffTime -> ProcessRestartAction Source #

Checks restart counts and worker start times to assess if the Supervisor error intensity has been breached, see ProcessRestartAction for possible outcomes.

execCapatazRestartStrategy :: SupervisorEnv -> ProcessId -> ProcessSpec -> Int -> IO () Source #

Sub-routine responsible of executing a SupervisorRestartStrategy.

execRestartAction :: SupervisorEnv -> ProcessId -> ProcessSpec -> Text -> UTCTime -> Int -> IO () Source #

Executes a restart action returned from the invokation of "calcRestartAction".

restartProcessList :: SupervisorEnv -> WorkerId -> RestartCount -> IO [Process] Source #

Restarts _all_ processes that are supervised by Supervisor, invoked when one worker green thread fails and causes sibling process threads to get restarted as well (e.g. AllForOne supervisor restart strategy).

forceRestartProcess :: SupervisorEnv -> Process -> IO () Source #

Sub-routine that is used when there is a restart request sent to a Process caused by an AllForOne restart from a failing sibling process.

restartWorker :: SupervisorEnv -> WorkerOptions -> WorkerId -> RestartCount -> IO Process Source #

Starts a new worker thread taking into account an existing WorkerId and keeping a RestartCount to manage the Supervisor error intensity.

restartSupervisor :: ParentSupervisorEnv -> SupervisorOptions -> ProcessId -> RestartCount -> IO Process Source #

Starts a new Supervisor thread taking into account an existing SupervisorId and keeping a RestartCount to manage the parent Supervisor error intensity.

handleWorkerCompleted :: SupervisorEnv -> Worker -> IO () Source #

Executes restart strategy for when a worker finishes it execution because of a completion (e.g. worker sub-routine finished without any errors).

handleProcessCompleted :: SupervisorEnv -> ProcessId -> UTCTime -> IO () Source #

Executes restart strategy for when a process finishes it execution because of a completion (e.g. worker sub-routine finished without any errors).

handleWorkerFailed :: SupervisorEnv -> Worker -> Int -> IO () Source #

Executes restart strategy for when a worker finishes it execution because of a failure.

handleSupervisorFailed :: SupervisorEnv -> Supervisor -> Int -> IO () Source #

Executes restart strategy for when a supervisor finishes it execution because of a failure.

handleProcessFailed :: SupervisorEnv -> WorkerId -> SomeException -> Int -> IO () Source #

Executes restart strategy for when a process finishes it execution because of a failure.

handleWorkerTerminated :: SupervisorEnv -> Worker -> Int -> IO () Source #

Executes restart strategy for when a worker finishes it execution because of a termination from its supervisor.

handleSupervisorTerminated :: SupervisorEnv -> Supervisor -> Int -> IO () Source #

Executes restart strategy for when a supervisor finishes it execution because of a termination from its parent supervisor.

handleProcessTerminated :: SupervisorEnv -> ProcessId -> Text -> Int -> IO () Source #

Executes restart strategy for when a process finishes it execution because of a termination from its supervisor.