Safe Haskell | None |
---|---|
Language | Haskell2010 |
- forkSupervisor :: MonadUnliftIO m => ParentSupervisorEnv m -> SupervisorOptions m -> Maybe (ProcessId, RestartCount) -> m (Supervisor m)
- buildSupervisorEnv :: MonadIO m => (CapatazEvent -> m ()) -> (SupervisorMessage m -> m ()) -> STM (SupervisorMessage m) -> SupervisorId -> SupervisorOptions m -> m (SupervisorEnv m)
- handleMonitorEvent :: MonadUnliftIO m => SupervisorEnv m -> MonitorEvent -> m Bool
- handleControlAction :: MonadUnliftIO m => SupervisorEnv m -> ControlAction m -> m Bool
- haltSupervisor :: MonadUnliftIO m => Text -> SupervisorEnv m -> m ()
- handleSupervisorMessage :: MonadUnliftIO m => SupervisorEnv m -> SupervisorMessage m -> m Bool
- supervisorLoop :: MonadUnliftIO m => (forall b. m b -> m b) -> ParentSupervisorEnv m -> SupervisorEnv m -> RestartCount -> m ()
- supervisorMain :: MonadUnliftIO m => ParentSupervisorEnv m -> SupervisorOptions m -> SupervisorId -> RestartCount -> m (Supervisor m)
- calcDiffSeconds :: MonadIO m => UTCTime -> m NominalDiffTime
- calcRestartAction :: SupervisorEnv m -> Int -> NominalDiffTime -> ProcessRestartAction
- execCapatazRestartStrategy :: MonadUnliftIO m => SupervisorEnv m -> ProcessId -> ProcessSpec m -> Int -> m ()
- execRestartAction :: MonadUnliftIO m => SupervisorEnv m -> ProcessId -> ProcessSpec m -> Text -> UTCTime -> Int -> m ()
- restartProcessList :: MonadUnliftIO m => SupervisorEnv m -> WorkerId -> RestartCount -> m [Process m]
- forceRestartProcess :: MonadIO m => SupervisorEnv m -> Process m -> m ()
- restartWorker :: MonadUnliftIO m => SupervisorEnv m -> WorkerOptions m -> WorkerId -> RestartCount -> m (Process m)
- restartSupervisor :: MonadUnliftIO m => ParentSupervisorEnv m -> SupervisorOptions m -> ProcessId -> RestartCount -> m (Process m)
- handleWorkerCompleted :: MonadUnliftIO m => SupervisorEnv m -> Worker m -> m ()
- handleProcessCompleted :: MonadUnliftIO m => SupervisorEnv m -> ProcessId -> UTCTime -> m ()
- handleWorkerFailed :: MonadUnliftIO m => SupervisorEnv m -> Worker m -> Int -> m ()
- handleSupervisorFailed :: MonadUnliftIO m => SupervisorEnv m -> Supervisor m -> Int -> m ()
- handleProcessFailed :: MonadUnliftIO m => SupervisorEnv m -> WorkerId -> SomeException -> Int -> m ()
- handleWorkerTerminated :: MonadUnliftIO m => SupervisorEnv m -> Worker m -> Int -> m ()
- handleSupervisorTerminated :: MonadUnliftIO m => SupervisorEnv m -> Supervisor m -> Int -> m ()
- handleProcessTerminated :: MonadUnliftIO m => SupervisorEnv m -> ProcessId -> Text -> Int -> m ()
Documentation
forkSupervisor :: MonadUnliftIO m => ParentSupervisorEnv m -> SupervisorOptions m -> Maybe (ProcessId, RestartCount) -> m (Supervisor m) 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 :: MonadIO m => (CapatazEvent -> m ()) -> (SupervisorMessage m -> m ()) -> STM (SupervisorMessage m) -> SupervisorId -> SupervisorOptions m -> m (SupervisorEnv m) Source #
Utility function that builds an utility record which is used on all internal APIs of the supervision logic.
handleMonitorEvent :: MonadUnliftIO m => SupervisorEnv m -> MonitorEvent -> m Bool Source #
Handles an event produced by one of the processes this supervisor monitors.
handleControlAction :: MonadUnliftIO m => SupervisorEnv m -> ControlAction m -> m Bool Source #
Handles an action triggered by the public Capataz API.
haltSupervisor :: MonadUnliftIO m => Text -> SupervisorEnv m -> m () Source #
Executes the shutdown operation of a Supervisor, including the termination of its supervised processes.
handleSupervisorMessage :: MonadUnliftIO m => SupervisorEnv m -> SupervisorMessage m -> m Bool Source #
Handles all messages that a Supervisor can receive from its monitored processes or from the public API.
supervisorLoop :: MonadUnliftIO m => (forall b. m b -> m b) -> ParentSupervisorEnv m -> SupervisorEnv m -> RestartCount -> m () Source #
This sub-routine executes the main thread loop of a Supervisor instance.
supervisorMain :: MonadUnliftIO m => ParentSupervisorEnv m -> SupervisorOptions m -> SupervisorId -> RestartCount -> m (Supervisor m) Source #
This sub-routine starts a Supervisor thread and initializes its processList.
calcDiffSeconds :: MonadIO m => UTCTime -> m NominalDiffTime Source #
Tracks difference between two timestamps so that we keep track of a Supervisor error intensity.
calcRestartAction :: SupervisorEnv m -> 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 :: MonadUnliftIO m => SupervisorEnv m -> ProcessId -> ProcessSpec m -> Int -> m () Source #
Sub-routine responsible of executing a SupervisorRestartStrategy.
execRestartAction :: MonadUnliftIO m => SupervisorEnv m -> ProcessId -> ProcessSpec m -> Text -> UTCTime -> Int -> m () Source #
Executes a restart action returned from the invokation of "calcRestartAction".
restartProcessList :: MonadUnliftIO m => SupervisorEnv m -> WorkerId -> RestartCount -> m [Process m] 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 :: MonadIO m => SupervisorEnv m -> Process m -> m () 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 :: MonadUnliftIO m => SupervisorEnv m -> WorkerOptions m -> WorkerId -> RestartCount -> m (Process m) Source #
Starts a new worker thread taking into account an existing WorkerId and keeping a RestartCount to manage the Supervisor error intensity.
restartSupervisor :: MonadUnliftIO m => ParentSupervisorEnv m -> SupervisorOptions m -> ProcessId -> RestartCount -> m (Process m) Source #
Starts a new Supervisor thread taking into account an existing SupervisorId and keeping a RestartCount to manage the parent Supervisor error intensity.
handleWorkerCompleted :: MonadUnliftIO m => SupervisorEnv m -> Worker m -> m () 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 :: MonadUnliftIO m => SupervisorEnv m -> ProcessId -> UTCTime -> m () 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 :: MonadUnliftIO m => SupervisorEnv m -> Worker m -> Int -> m () Source #
Executes restart strategy for when a worker finishes it execution because of a failure.
handleSupervisorFailed :: MonadUnliftIO m => SupervisorEnv m -> Supervisor m -> Int -> m () Source #
Executes restart strategy for when a supervisor finishes it execution because of a failure.
handleProcessFailed :: MonadUnliftIO m => SupervisorEnv m -> WorkerId -> SomeException -> Int -> m () Source #
Executes restart strategy for when a process finishes it execution because of a failure.
handleWorkerTerminated :: MonadUnliftIO m => SupervisorEnv m -> Worker m -> Int -> m () Source #
Executes restart strategy for when a worker finishes it execution because of a termination from its supervisor.
handleSupervisorTerminated :: MonadUnliftIO m => SupervisorEnv m -> Supervisor m -> Int -> m () Source #
Executes restart strategy for when a supervisor finishes it execution because of a termination from its parent supervisor.
handleProcessTerminated :: MonadUnliftIO m => SupervisorEnv m -> ProcessId -> Text -> Int -> m () Source #
Executes restart strategy for when a process finishes it execution because of a termination from its supervisor.