-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Supervisors for The Cloud Haskell Application Platform -- -- A part of the Cloud Haskell framework This package implements a -- process which supervises a set of other processes, referred to as its -- children. These child processes can be either workers (i.e., processes -- that do something useful in your application) or other supervisors. In -- this way, supervisors may be used to build a hierarchical process -- structure called a supervision tree, which provides a convenient -- structure for building fault tolerant software. For detailed -- information see Control.Distributed.Process.Supervisor @package distributed-process-supervisor @version 0.1.3.2 -- | This module implements a process which supervises a set of other -- processes, referred to as its children. These child processes -- can be either workers (i.e., processes that do something useful in -- your application) or other supervisors. In this way, supervisors may -- be used to build a hierarchical process structure called a supervision -- tree, which provides a convenient structure for building fault -- tolerant software. -- -- Unless otherwise stated, all functions in this module will cause the -- calling process to exit unless the specified supervisor process -- exists. -- --
-- let children = [a..d] -- let failure = c -- restartsFor RestartOne children failure = [c] -- restartsFor RestartAll children failure = [a,b,c,d] -- restartsFor RestartLeft children failure = [a,b,c] -- restartsFor RestartRight children failure = [c,d] ---- --
-- stop a -- start a -- stop b -- start b -- stop c -- start c ---- -- By contrast, RestartInOrder will first run through the -- selected list of children, stopping them. Then, once all the children -- have been stopped, it will make a second pass, to handle (re)starting -- them. No child is started until all children have been stopped, as the -- following imaginary example demonstrates: -- --
-- stop a -- stop b -- stop c -- start a -- start b -- start c ---- -- Both the previous examples have shown children being stopped and -- started from left to right, but that is up to the user. The -- RestartMode data type's constructors take a -- RestartOrder, which determines whether the selected children -- will be processed from LeftToRight or RightToLeft. -- -- Sometimes it is desireable to stop children in one order and start -- them in the opposite. This is typically the case when children are in -- some way dependent on one another, such that restarting them in the -- wrong order might cause the system to misbehave. For this scenarios, -- there is another RestartMode that will shut children down in -- the given order, but then restarts them in the reverse. Using -- RestartRevOrder mode, if we have children [a,b,c] -- such that b depends on a and c on -- b, we can stop them in the reverse of their startup order, -- but restart them the other way around like so: -- --
-- RestartRevOrder RightToLeft ---- -- The effect will be thus: -- --
-- stop c -- stop b -- stop a -- start a -- start b -- start c ---- --
-- start = spawnLocal . run --start :: RestartStrategy -> ShutdownMode -> [ChildSpec] -> Process SupervisorPid -- | Run the supplied children using the provided restart strategy. run :: RestartStrategy -> ShutdownMode -> [ChildSpec] -> Process () data MaxRestarts -- | Smart constructor for MaxRestarts. The maximum restart count -- must be a positive integer. maxRestarts :: Int -> MaxRestarts -- | A compulsary limit on the number of restarts that a supervisor will -- tolerate before it terminates all child processes and then itself. If -- > MaxRestarts occur within the specified -- TimeInterval, termination will occur. This prevents the -- supervisor from entering an infinite loop of child process -- terminations and restarts. data RestartLimit RestartLimit :: !MaxRestarts -> !TimeInterval -> RestartLimit [maxR] :: RestartLimit -> !MaxRestarts [maxT] :: RestartLimit -> !TimeInterval limit :: MaxRestarts -> TimeInterval -> RestartLimit defaultLimits :: RestartLimit data RestartMode -- | stop then start each child sequentially, i.e., foldlM -- stopThenStart children RestartEach :: !RestartOrder -> RestartMode [order] :: RestartMode -> !RestartOrder -- | stop all children first, then restart them sequentially RestartInOrder :: !RestartOrder -> RestartMode [order] :: RestartMode -> !RestartOrder -- | stop all children in the given order, but start them in reverse RestartRevOrder :: !RestartOrder -> RestartMode [order] :: RestartMode -> !RestartOrder data RestartOrder LeftToRight :: RestartOrder RightToLeft :: RestartOrder -- | Strategy used by a supervisor to handle child restarts, whether due to -- unexpected child failure or explicit restart requests from a client. -- -- Some terminology: We refer to child processes managed by the same -- supervisor as siblings. When restarting a child process, the -- RestartNone policy indicates that sibling processes should be -- left alone, whilst the RestartAll policy will cause all -- children to be restarted (in the same order they were started). -- -- The other two restart strategies refer to prior and -- subsequent siblings, which describe's those children's -- configured position (i.e., insertion order). These latter modes allow -- one to control the order in which siblings are restarted, and to -- exclude some siblings from the restart without having to resort to -- grouping them using a child supervisor. data RestartStrategy -- | restart only the failed child process RestartOne :: !RestartLimit -> RestartStrategy [intensity] :: RestartStrategy -> !RestartLimit -- | also restart all siblings RestartAll :: !RestartLimit -> !RestartMode -> RestartStrategy [intensity] :: RestartStrategy -> !RestartLimit [mode] :: RestartStrategy -> !RestartMode -- | restart prior siblings (i.e., prior start order) RestartLeft :: !RestartLimit -> !RestartMode -> RestartStrategy [intensity] :: RestartStrategy -> !RestartLimit [mode] :: RestartStrategy -> !RestartMode -- | restart subsequent siblings (i.e., subsequent start order) RestartRight :: !RestartLimit -> !RestartMode -> RestartStrategy [intensity] :: RestartStrategy -> !RestartLimit [mode] :: RestartStrategy -> !RestartMode data ShutdownMode SequentialShutdown :: !RestartOrder -> ShutdownMode ParallelShutdown :: ShutdownMode -- | Provides a default RestartStrategy for RestartOne. -- > restartOne = RestartOne defaultLimits restartOne :: RestartStrategy -- | Provides a default RestartStrategy for RestartAll. -- > restartOne = RestartAll defaultLimits (RestartEach LeftToRight) restartAll :: RestartStrategy -- | Provides a default RestartStrategy for RestartLeft. -- > restartOne = RestartLeft defaultLimits (RestartEach LeftToRight) restartLeft :: RestartStrategy -- | Provides a default RestartStrategy for RestartRight. -- > restartOne = RestartRight defaultLimits (RestartEach LeftToRight) restartRight :: RestartStrategy -- | Add a new child. addChild :: Addressable a => a -> ChildSpec -> Process AddChildResult data AddChildResult ChildAdded :: !ChildRef -> AddChildResult ChildFailedToStart :: !StartFailure -> AddChildResult data StartChildResult ChildStartOk :: !ChildRef -> StartChildResult ChildStartFailed :: !StartFailure -> StartChildResult ChildStartUnknownId :: StartChildResult ChildStartInitIgnored :: StartChildResult -- | Start an existing (configured) child. The ChildSpec must -- already be present (see addChild), otherwise the operation will -- fail. startChild :: Addressable a => a -> ChildKey -> Process StartChildResult -- | Atomically add and start a new child spec. Will fail if a child with -- the given key is already present. startNewChild :: Addressable a => a -> ChildSpec -> Process AddChildResult -- | Terminate a running child. terminateChild :: Addressable a => a -> ChildKey -> Process TerminateChildResult data TerminateChildResult TerminateChildOk :: TerminateChildResult TerminateChildUnknownId :: TerminateChildResult -- | Delete a supervised child. The child must already be stopped (see -- terminateChild). deleteChild :: Addressable a => a -> ChildKey -> Process DeleteChildResult -- | The result of a call to removeChild. data DeleteChildResult -- | the child specification was successfully removed ChildDeleted :: DeleteChildResult -- | the child specification was not found ChildNotFound :: DeleteChildResult -- | the child was not removed, as it was not stopped. ChildNotStopped :: !ChildRef -> DeleteChildResult -- | Forcibly restart a running child. restartChild :: Addressable a => a -> ChildKey -> Process RestartChildResult data RestartChildResult ChildRestartOk :: !ChildRef -> RestartChildResult ChildRestartFailed :: !StartFailure -> RestartChildResult ChildRestartUnknownId :: RestartChildResult ChildRestartIgnored :: RestartChildResult -- | Gracefully terminate a running supervisor. Returns immediately if the -- address cannot be resolved. shutdown :: Resolvable a => a -> Process () -- | As shutdown, but waits until the supervisor process has exited, -- at which point the caller can be sure that all children have also -- stopped. Returns immediately if the address cannot be resolved. shutdownAndWait :: Resolvable a => a -> Process () -- | Lookup a possibly supervised child, given its ChildKey. lookupChild :: Addressable a => a -> ChildKey -> Process (Maybe (ChildRef, ChildSpec)) -- | List all know (i.e., configured) children. listChildren :: Addressable a => a -> Process [Child] data SupervisorStats SupervisorStats :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> SupervisorStats [_children] :: SupervisorStats -> Int [_supervisors] :: SupervisorStats -> Int [_workers] :: SupervisorStats -> Int [_running] :: SupervisorStats -> Int [_activeSupervisors] :: SupervisorStats -> Int [_activeWorkers] :: SupervisorStats -> Int [totalRestarts] :: SupervisorStats -> Int -- | Obtain statistics about a running supervisor. statistics :: Addressable a => a -> Process (SupervisorStats) -- | Provides failure information when (re-)start failure is indicated. data StartFailure -- | a child with this ChildKey already exists StartFailureDuplicateChild :: !ChildRef -> StartFailure -- | the child is already up and running StartFailureAlreadyRunning :: !ChildRef -> StartFailure -- | a closure cannot be resolved StartFailureBadClosure :: !StaticLabel -> StartFailure -- | a child died (almost) immediately on starting StartFailureDied :: !DiedReason -> StartFailure data ChildInitFailure ChildInitFailure :: !String -> ChildInitFailure ChildInitIgnore :: ChildInitFailure instance GHC.Generics.Constructor Control.Distributed.Process.Supervisor.C1_0IgnoreChildReq instance GHC.Generics.Datatype Control.Distributed.Process.Supervisor.D1IgnoreChildReq instance GHC.Generics.Constructor Control.Distributed.Process.Supervisor.C1_0TerminateChildReq instance GHC.Generics.Datatype Control.Distributed.Process.Supervisor.D1TerminateChildReq instance GHC.Generics.Constructor Control.Distributed.Process.Supervisor.C1_0RestartChildReq instance GHC.Generics.Datatype Control.Distributed.Process.Supervisor.D1RestartChildReq instance GHC.Generics.Constructor Control.Distributed.Process.Supervisor.C1_0StartChildReq instance GHC.Generics.Datatype Control.Distributed.Process.Supervisor.D1StartChildReq instance GHC.Generics.Constructor Control.Distributed.Process.Supervisor.C1_0AddChildReq instance GHC.Generics.Datatype Control.Distributed.Process.Supervisor.D1AddChildReq instance GHC.Generics.Constructor Control.Distributed.Process.Supervisor.C1_0ListReq instance GHC.Generics.Datatype Control.Distributed.Process.Supervisor.D1ListReq instance GHC.Generics.Constructor Control.Distributed.Process.Supervisor.C1_0StatsReq instance GHC.Generics.Datatype Control.Distributed.Process.Supervisor.D1StatsReq instance GHC.Generics.Constructor Control.Distributed.Process.Supervisor.C1_0FindReq instance GHC.Generics.Datatype Control.Distributed.Process.Supervisor.D1FindReq instance GHC.Generics.Constructor Control.Distributed.Process.Supervisor.C1_0DeleteChild instance GHC.Generics.Datatype Control.Distributed.Process.Supervisor.D1DeleteChild instance GHC.Generics.Generic Control.Distributed.Process.Supervisor.IgnoreChildReq instance GHC.Classes.Eq Control.Distributed.Process.Supervisor.TerminateChildReq instance GHC.Show.Show Control.Distributed.Process.Supervisor.TerminateChildReq instance GHC.Generics.Generic Control.Distributed.Process.Supervisor.TerminateChildReq instance GHC.Classes.Eq Control.Distributed.Process.Supervisor.RestartChildReq instance GHC.Show.Show Control.Distributed.Process.Supervisor.RestartChildReq instance GHC.Generics.Generic Control.Distributed.Process.Supervisor.RestartChildReq instance GHC.Generics.Generic Control.Distributed.Process.Supervisor.StartChildReq instance GHC.Show.Show Control.Distributed.Process.Supervisor.AddChildReq instance GHC.Generics.Generic Control.Distributed.Process.Supervisor.AddChildReq instance GHC.Generics.Generic Control.Distributed.Process.Supervisor.ListReq instance GHC.Generics.Generic Control.Distributed.Process.Supervisor.StatsReq instance GHC.Generics.Generic Control.Distributed.Process.Supervisor.FindReq instance GHC.Generics.Generic Control.Distributed.Process.Supervisor.DeleteChild instance Control.Distributed.Process.Supervisor.ToChildStart (Control.Distributed.Static.Closure (Control.Distributed.Process.Internal.Types.Process ())) instance Control.Distributed.Process.Supervisor.ToChildStart (Control.Distributed.Static.Closure (Control.Distributed.Process.Supervisor.Types.SupervisorPid -> Control.Distributed.Process.Internal.Types.Process (Control.Distributed.Process.Supervisor.Types.ChildPid, Control.Distributed.Process.Internal.Types.Message))) instance Control.Distributed.Process.Supervisor.ToChildStart (Control.Distributed.Process.Internal.Types.Process ()) instance Control.Distributed.Process.Extras.Internal.Types.Resolvable a => Control.Distributed.Process.Supervisor.ToChildStart (Control.Distributed.Process.Supervisor.Types.SupervisorPid -> Control.Distributed.Process.Internal.Types.Process a) instance Data.Binary.Class.Binary Control.Distributed.Process.Supervisor.DeleteChild instance Control.DeepSeq.NFData Control.Distributed.Process.Supervisor.DeleteChild instance Data.Binary.Class.Binary Control.Distributed.Process.Supervisor.FindReq instance Control.DeepSeq.NFData Control.Distributed.Process.Supervisor.FindReq instance Data.Binary.Class.Binary Control.Distributed.Process.Supervisor.StatsReq instance Control.DeepSeq.NFData Control.Distributed.Process.Supervisor.StatsReq instance Data.Binary.Class.Binary Control.Distributed.Process.Supervisor.ListReq instance Control.DeepSeq.NFData Control.Distributed.Process.Supervisor.ListReq instance Data.Binary.Class.Binary Control.Distributed.Process.Supervisor.AddChildReq instance Control.DeepSeq.NFData Control.Distributed.Process.Supervisor.AddChildReq instance Data.Binary.Class.Binary Control.Distributed.Process.Supervisor.StartChildReq instance Control.DeepSeq.NFData Control.Distributed.Process.Supervisor.StartChildReq instance Data.Binary.Class.Binary Control.Distributed.Process.Supervisor.RestartChildReq instance Control.DeepSeq.NFData Control.Distributed.Process.Supervisor.RestartChildReq instance Data.Binary.Class.Binary Control.Distributed.Process.Supervisor.TerminateChildReq instance Control.DeepSeq.NFData Control.Distributed.Process.Supervisor.TerminateChildReq instance Data.Binary.Class.Binary Control.Distributed.Process.Supervisor.IgnoreChildReq instance Control.DeepSeq.NFData Control.Distributed.Process.Supervisor.IgnoreChildReq instance Control.Distributed.Process.Extras.SystemLog.Logger Control.Distributed.Process.Supervisor.LogSink