capataz-0.2.1.0: OTP-like supervision trees in Haskell

Safe HaskellNone
LanguageHaskell2010

Control.Concurrent.Capataz.Internal.Core

Description

This module contains:

  • Functions exported on the public API
  • High level message handlers of the supervisor thread loop
Synopsis

Documentation

class HasSupervisor a where Source #

Utility typeclass to call public supervision API with types that contain a supervisor (e.g. Capataz record).

Methods

getSupervisor :: a m -> Supervisor m Source #

Fetches a supervisor from a record internals.

forkWorker Source #

Arguments

:: (MonadIO m, HasSupervisor supervisor) 
=> WorkerOptions m

Worker options (restart, name, callbacks, etc)

-> supervisor m

Supervisor that supervises the worker

-> m WorkerId

An identifier that can be used to terminate the Worker

Creates a green thread from an IO () sub-routine. Depending in options defined in the WorkerOptions record, it will automatically restart this sub-routine in case of failures.

See documentation of related functions:

forkSupervisor Source #

Arguments

:: (MonadIO m, HasSupervisor parentSupervisor) 
=> SupervisorOptions m

Supervisor options

-> parentSupervisor m

Parent supervisor instance that supervises new supervisor

-> m (Supervisor m)

A record used to dynamically create and supervise other processes

Creates a green thread which monitors other green threads for failures and restarts them using settings defined on SupervisorOptions.

See documentation of related functions:

forkCapataz :: (MonadUnliftIO m, MonadIO m) => Text -> (CapatazOptions m -> CapatazOptions m) -> m (Capataz m) Source #

Creates a Capataz record, which holds both a root supervisor and a Teardown to shut down the system. The root supervisor monitors failures on process threads defined with CapatazOptions or created dynamically using forkWorker or forkSupervisor.

terminateProcess :: (MonadIO m, HasSupervisor supervisor) => Text -> ProcessId -> supervisor m -> m Bool Source #

Stops the execution of a green thread being supervised by the given supervisor.

IMPORTANT If ProcessId maps to a worker that is configured with a Permanent worker restart strategy, the worker green thread __will be restarted again__.

terminateCapataz :: MonadIO m => Capataz m -> m TeardownResult Source #

Terminates a Capataz system (all supervised threads) and returns a TeardownResult

Since: 0.2.0.0

terminateCapataz_ :: MonadIO m => Capataz m -> m () Source #

Terminates a Capataz system (all supervised threads)

Since: 0.2.0.0

joinCapatazThread :: MonadIO m => Capataz m -> m () Source #

Joins the thread of the root supervisor of the given capataz system to the current thread.

getSupervisorProcessId :: Supervisor m -> ProcessId Source #

Gets the process identifier of a Supervisor; normally used for termination.

getSupervisorAsync :: Supervisor m -> Async () Source #

Gets the Async of a Supervisor thread.

NOTE: There is no way to get the Async value of the root supervisor; this is done on-purpose to avoid error scenarios.

getCapatazTeardown :: Capataz m -> Teardown Source #

Gets Teardown record of this capataz system.