capataz-0.1.0.1: 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).

Minimal complete definition

getSupervisor

Methods

getSupervisor :: a -> Supervisor Source #

Fetches a supervisor from a record internals.

forkWorker Source #

Arguments

:: HasSupervisor supervisor 
=> WorkerOptions

Worker options (restart, name, callbacks, etc)

-> supervisor

Supervisor that supervises the worker

-> IO 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:

  • "buildWorkerOptionsWithDefault"
  • "buildWorkerOptions"

forkSupervisor Source #

Arguments

:: HasSupervisor parentSupervisor 
=> SupervisorOptions

Supervisor options

-> parentSupervisor

Parent supervisor instance that supervises new supervisor

-> IO Supervisor

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:

  • "buildSupervisorOptionsWithDefault"
  • "buildSupervisorOptions"

forkCapataz :: Text -> (CapatazOptions -> CapatazOptions) -> IO Capataz 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 "supervisorProcessSpecList" or created dynamically using "forkWorker" or "forkSupervisor".

terminateProcess :: HasSupervisor supervisor => Text -> ProcessId -> supervisor -> IO Bool Source #

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

NOTE: If ProcessId maps to a worker that is configured with a Permanent worker restart strategy, the worker green thread will be restarted again.

joinCapatazThread :: Capataz -> IO () Source #

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

getSupervisorProcessId :: Supervisor -> ProcessId Source #

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

getSupervisorAsync :: Supervisor -> 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 to avoid error scenarios.

getCapatazTeardown :: Capataz -> Teardown Source #

Gets Teardown record of this capataz system.