Safe Haskell | None |
---|---|
Language | Haskell2010 |
Control.Distributed.Process.ManagedProcess.Internal.Types
Contents
Description
Types used throughout the ManagedProcess framework
Synopsis
- data InitResult s
- = InitOk s Delay
- | InitStop String
- | InitIgnore
- data GenProcess s a
- runProcess :: State s -> GenProcess s a -> Process (a, State s)
- lift :: Process a -> GenProcess s a
- liftIO :: IO a -> GenProcess s a
- data ProcessState s = ProcessState {
- timeoutSpec :: RecvTimeoutPolicy
- procDef :: ProcessDefinition s
- procPrio :: [DispatchPriority s]
- procFilters :: [DispatchFilter s]
- usrTimeout :: Delay
- sysTimeout :: Timer
- usrTimers :: TimerMap
- internalQ :: Queue
- procState :: s
- type State s = IORef (ProcessState s)
- type Queue = PriorityQ Int Message
- type Limit = Maybe Int
- data Condition s m
- data ProcessAction s
- = ProcessSkip
- | ProcessActivity (GenProcess s ())
- | ProcessExpression (GenProcess s (ProcessAction s))
- | ProcessContinue s
- | ProcessTimeout Delay s
- | ProcessHibernate TimeInterval s
- | ProcessStop ExitReason
- | ProcessStopping s ExitReason
- | ProcessBecome (ProcessDefinition s) s
- data ProcessReply r s
- = ProcessReply r (ProcessAction s)
- | ProcessReject String (ProcessAction s)
- | NoReply (ProcessAction s)
- type Action s = Process (ProcessAction s)
- type Reply b s = Process (ProcessReply b s)
- type ActionHandler s a = s -> a -> Action s
- type CallHandler s a b = s -> a -> Reply b s
- type CastHandler s a = ActionHandler s a
- type StatelessHandler s a = a -> s -> Action s
- type DeferredCallHandler s a b = CallRef b -> CallHandler s a b
- type StatelessCallHandler s a b = CallRef b -> a -> Reply b s
- type InfoHandler s a = ActionHandler s a
- type ChannelHandler s a b = SendPort b -> ActionHandler s a
- type StatelessChannelHandler s a b = SendPort b -> StatelessHandler s a
- type InitHandler a s = a -> Process (InitResult s)
- type ShutdownHandler s = ExitState s -> ExitReason -> Process ()
- data ExitState s
- = CleanShutdown s
- | LastKnown s
- isCleanShutdown :: ExitState s -> Bool
- exitState :: ExitState s -> s
- type TimeoutHandler s = ActionHandler s Delay
- data UnhandledMessagePolicy
- = Terminate
- | DeadLetter ProcessId
- | Log
- | Drop
- data ProcessDefinition s = ProcessDefinition {}
- newtype Priority a = Priority {}
- data DispatchPriority s
- = PrioritiseCall { }
- | PrioritiseCast { }
- | PrioritiseInfo { }
- data DispatchFilter s
- = (Serializable a, Serializable b) => FilterApi { }
- | Serializable a => FilterAny { }
- | FilterRaw { }
- | FilterState {
- stateFilter :: s -> Process (Maybe (Filter s))
- data Filter s
- = FilterOk s
- | FilterSafe s
- | Show m => FilterReject m s
- | FilterSkip s
- | FilterStop s ExitReason
- data PrioritisedProcessDefinition s = PrioritisedProcessDefinition {
- processDef :: ProcessDefinition s
- priorities :: [DispatchPriority s]
- filters :: [DispatchFilter s]
- recvTimeout :: RecvTimeoutPolicy
- data RecvTimeoutPolicy
- newtype ControlChannel m = ControlChannel {
- unControl :: (SendPort (Message m ()), ReceivePort (Message m ()))
- newControlChan :: Serializable m => Process (ControlChannel m)
- newtype ControlPort m = ControlPort {}
- channelControlPort :: ControlChannel m -> ControlPort m
- data Dispatcher s
- = (Serializable a, Serializable b) => Dispatch {
- dispatch :: s -> Message a b -> Process (ProcessAction s)
- | (Serializable a, Serializable b) => DispatchIf {
- dispatch :: s -> Message a b -> Process (ProcessAction s)
- dispatchIf :: s -> Message a b -> Bool
- = (Serializable a, Serializable b) => Dispatch {
- data ExternDispatcher s
- = (Serializable a, Serializable b) => DispatchCC {
- channel :: ReceivePort (Message a b)
- dispatchChan :: s -> Message a b -> Process (ProcessAction s)
- | Serializable a => DispatchSTM {
- stmAction :: STM a
- dispatchStm :: s -> a -> Process (ProcessAction s)
- matchStm :: Match Message
- matchAnyStm :: forall m. (Message -> m) -> Match m
- = (Serializable a, Serializable b) => DispatchCC {
- data DeferredDispatcher s = DeferredDispatcher {
- dispatchInfo :: s -> Message -> Process (Maybe (ProcessAction s))
- data ExitSignalDispatcher s = ExitSignalDispatcher {
- dispatchExit :: s -> ProcessId -> Message -> Process (Maybe (ProcessAction s))
- class MessageMatcher (d :: Type -> Type) where
- matchDispatch :: UnhandledMessagePolicy -> s -> d s -> Match (ProcessAction s)
- class ExternMatcher (d :: Type -> Type) where
- matchExtern :: UnhandledMessagePolicy -> s -> d s -> Match Message
- matchMapExtern :: forall m s. UnhandledMessagePolicy -> s -> (Message -> m) -> d s -> Match m
- data Message a b
- = CastMessage a
- | CallMessage a (CallRef b)
- | ChanMessage a (SendPort b)
- data CallResponse a = CallResponse a CallId
- type CallId = MonitorRef
- newtype CallRef a = CallRef {}
- data CallRejected = CallRejected String CallId
- makeRef :: Recipient -> CallId -> CallRef a
- caller :: Message a b -> Maybe Recipient
- rejectToCaller :: Message a b -> String -> Process ()
- recipient :: CallRef a -> Recipient
- tag :: CallRef a -> CallId
- initCall :: (Addressable s, Serializable a, Serializable b) => s -> a -> Process (CallRef b)
- unsafeInitCall :: (Addressable s, NFSerializable a, NFSerializable b) => s -> a -> Process (CallRef b)
- waitResponse :: Serializable b => Maybe TimeInterval -> CallRef b -> Process (Maybe (Either ExitReason b))
Exported data types
data InitResult s Source #
Return type for and InitHandler
expression.
Constructors
InitOk s Delay | |
InitStop String | |
InitIgnore |
data GenProcess s a Source #
StateT based monad for prioritised process loops.
Instances
runProcess :: State s -> GenProcess s a -> Process (a, State s) Source #
Run an action in the GenProcess
monad.
lift :: Process a -> GenProcess s a Source #
Lift an action in the Process
monad to GenProcess
.
liftIO :: IO a -> GenProcess s a Source #
Lift an IO action directly into GenProcess
, liftIO = lift . Process.LiftIO
.
data ProcessState s Source #
Internal state of a prioritised process loop.
Constructors
ProcessState | |
Fields
|
Instances
MonadState (State s) (GenProcess s) Source # | |
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods get :: GenProcess s (State s) # put :: State s -> GenProcess s () # state :: (State s -> (a, State s)) -> GenProcess s a # |
type State s = IORef (ProcessState s) Source #
Prioritised process state, held as an IORef
.
Wraps a predicate that is used to determine whether or not a handler is valid based on some combination of the current process state, the type and/or value of the input message or both.
data ProcessAction s Source #
The action taken by a process after a handler has run and its updated state. See "Control.Distributed.Process.ManagedProcess.Server.continue" "Control.Distributed.Process.ManagedProcess.Server.timeoutAfter" "Control.Distributed.Process.ManagedProcess.Server.hibernate" "Control.Distributed.Process.ManagedProcess.Server.stop" "Control.Distributed.Process.ManagedProcess.Server.stopWith"
Also see "Control.Distributed.Process.Management.Priority.act" and "Control.Distributed.Process.ManagedProcess.Priority.runAfter".
And other actions. This type should not be used directly.
Constructors
ProcessSkip | |
ProcessActivity (GenProcess s ()) | run the given activity |
ProcessExpression (GenProcess s (ProcessAction s)) | evaluate an expression |
ProcessContinue s | continue with (possibly new) state |
ProcessTimeout Delay s | timeout if no messages are received |
ProcessHibernate TimeInterval s | hibernate for delay |
ProcessStop ExitReason | stop the process, giving |
ProcessStopping s ExitReason | stop the process with |
ProcessBecome (ProcessDefinition s) s | changes the current process definition |
data ProcessReply r s Source #
Returned from handlers for the synchronous call
protocol, encapsulates
the reply data and the action to take after sending the reply. A handler
can return NoReply
if they wish to ignore the call.
Constructors
ProcessReply r (ProcessAction s) | |
ProcessReject String (ProcessAction s) | |
NoReply (ProcessAction s) |
type Action s = Process (ProcessAction s) Source #
An action (server state transition) in the Process
monad
type Reply b s = Process (ProcessReply b s) Source #
An action (server state transition) causing a reply to a caller, in the
Process
monad
type ActionHandler s a = s -> a -> Action s Source #
An expression used to handle a message
type CallHandler s a b = s -> a -> Reply b s Source #
An expression used to handle a message and providing a reply
type CastHandler s a = ActionHandler s a Source #
An expression used to handle a cast message
type StatelessHandler s a = a -> s -> Action s Source #
An expression used to ignore server state during handling
type DeferredCallHandler s a b = CallRef b -> CallHandler s a b Source #
An expression used to handle a call message where the reply is deferred
via the CallRef
type StatelessCallHandler s a b = CallRef b -> a -> Reply b s Source #
An expression used to handle a call message ignoring server state
type InfoHandler s a = ActionHandler s a Source #
An expression used to handle an info message
type ChannelHandler s a b = SendPort b -> ActionHandler s a Source #
An expression used to handle a channel message
type StatelessChannelHandler s a b = SendPort b -> StatelessHandler s a Source #
An expression used to handle a channel message in a stateless process
type InitHandler a s = a -> Process (InitResult s) Source #
An expression used to initialise a process with its state
type ShutdownHandler s = ExitState s -> ExitReason -> Process () Source #
An expression used to handle process termination
Informs a shutdown handler of whether it is running due to a clean shutdown, or in response to an unhandled exception.
Constructors
CleanShutdown s | given when an ordered shutdown is underway |
LastKnown s |
isCleanShutdown :: ExitState s -> Bool Source #
True
if the ExitState
is CleanShutdown
, otherwise False
.
type TimeoutHandler s = ActionHandler s Delay Source #
An expression used to handle process timeouts
data UnhandledMessagePolicy Source #
Policy for handling unexpected messages, i.e., messages which are not
sent using the call
or cast
APIs, and which are not handled by any of the
handleInfo
handlers.
Constructors
Terminate | stop immediately, giving |
DeadLetter ProcessId | forward the message to the given recipient |
Log | log messages, then behave identically to |
Drop | dequeue and then drop/ignore the message |
Instances
Show UnhandledMessagePolicy Source # | |
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods showsPrec :: Int -> UnhandledMessagePolicy -> ShowS # show :: UnhandledMessagePolicy -> String # showList :: [UnhandledMessagePolicy] -> ShowS # | |
Eq UnhandledMessagePolicy Source # | |
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods (==) :: UnhandledMessagePolicy -> UnhandledMessagePolicy -> Bool # (/=) :: UnhandledMessagePolicy -> UnhandledMessagePolicy -> Bool # |
data ProcessDefinition s Source #
Stores the functions that determine runtime behaviour in response to incoming messages and a policy for responding to unhandled messages.
Constructors
ProcessDefinition | |
Fields
|
Priority of a message, encoded as an Int
data DispatchPriority s Source #
Dispatcher for prioritised handlers
Constructors
PrioritiseCall | |
PrioritiseCast | |
PrioritiseInfo | |
data DispatchFilter s Source #
Provides dispatch from a variety of inputs to a typed filter handler.
Constructors
(Serializable a, Serializable b) => FilterApi | |
Serializable a => FilterAny | |
FilterRaw | |
FilterState | |
Fields
|
Given as the result of evaluating a DispatchFilter. This type is intended for internal use. For an API for working with filters, see Control.Distributed.Process.ManagedProcess.Priority.
Constructors
FilterOk s | |
FilterSafe s | |
Show m => FilterReject m s | |
FilterSkip s | |
FilterStop s ExitReason |
data PrioritisedProcessDefinition s Source #
A ProcessDefinition
decorated with DispatchPriority
for certain
input domains.
Constructors
PrioritisedProcessDefinition | |
Fields
|
data RecvTimeoutPolicy Source #
For a PrioritisedProcessDefinition
, this policy determines for how long
the receive loop should continue draining the process' mailbox before
processing its received mail (in priority order).
If a prioritised managed process is receiving a lot of messages (into its real mailbox), the server might never get around to actually processing its inputs. This (mandatory) policy provides a guarantee that eventually (i.e., after a specified number of received messages or time interval), the server will stop removing messages from its mailbox and process those it has already received.
Constructors
RecvMaxBacklog Int | |
RecvTimer TimeInterval |
newtype ControlChannel m Source #
Provides a means for servers to listen on a separate, typed control channel, thereby segregating the channel from their regular (and potentially busy) mailbox.
Constructors
ControlChannel | |
Fields
|
newControlChan :: Serializable m => Process (ControlChannel m) Source #
Creates a new ControlChannel
.
newtype ControlPort m Source #
The writable end of a ControlChannel
.
Constructors
ControlPort | |
Instances
Serializable m => Binary (ControlPort m) Source # | |
Show (ControlPort m) Source # | |
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods showsPrec :: Int -> ControlPort m -> ShowS # show :: ControlPort m -> String # showList :: [ControlPort m] -> ShowS # | |
Eq (ControlPort m) Source # | |
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods (==) :: ControlPort m -> ControlPort m -> Bool # (/=) :: ControlPort m -> ControlPort m -> Bool # |
channelControlPort :: ControlChannel m -> ControlPort m Source #
Obtain an opaque expression for communicating with a ControlChannel
.
data Dispatcher s Source #
Provides dispatch from cast and call messages to a typed handler.
Constructors
(Serializable a, Serializable b) => Dispatch | |
Fields
| |
(Serializable a, Serializable b) => DispatchIf | |
Fields
|
Instances
MessageMatcher Dispatcher Source # | |
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods matchDispatch :: UnhandledMessagePolicy -> s -> Dispatcher s -> Match (ProcessAction s) Source # |
data ExternDispatcher s Source #
Provides dispatch for channels and STM actions
Constructors
(Serializable a, Serializable b) => DispatchCC | |
Fields
| |
Serializable a => DispatchSTM | |
Fields
|
Instances
ExternMatcher ExternDispatcher Source # | |
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods matchExtern :: UnhandledMessagePolicy -> s -> ExternDispatcher s -> Match Message Source # matchMapExtern :: forall m s. UnhandledMessagePolicy -> s -> (Message -> m) -> ExternDispatcher s -> Match m Source # | |
MessageMatcher ExternDispatcher Source # | |
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods matchDispatch :: UnhandledMessagePolicy -> s -> ExternDispatcher s -> Match (ProcessAction s) Source # |
data DeferredDispatcher s Source #
Provides dispatch for any input, returns Nothing
for unhandled messages.
Constructors
DeferredDispatcher | |
Fields
|
data ExitSignalDispatcher s Source #
Provides dispatch for any exit signal - returns Nothing
for unhandled exceptions
Constructors
ExitSignalDispatcher | |
Fields
|
class MessageMatcher (d :: Type -> Type) where Source #
Defines the means of dispatching inbound messages to a handler
Methods
matchDispatch :: UnhandledMessagePolicy -> s -> d s -> Match (ProcessAction s) Source #
Instances
MessageMatcher Dispatcher Source # | |
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods matchDispatch :: UnhandledMessagePolicy -> s -> Dispatcher s -> Match (ProcessAction s) Source # | |
MessageMatcher ExternDispatcher Source # | |
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods matchDispatch :: UnhandledMessagePolicy -> s -> ExternDispatcher s -> Match (ProcessAction s) Source # |
class ExternMatcher (d :: Type -> Type) where Source #
Defines the means of dispatching messages from external channels (e.g. those defined in terms of ControlChannel, and STM actions) to a handler.
Methods
matchExtern :: UnhandledMessagePolicy -> s -> d s -> Match Message Source #
matchMapExtern :: forall m s. UnhandledMessagePolicy -> s -> (Message -> m) -> d s -> Match m Source #
Instances
ExternMatcher ExternDispatcher Source # | |
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods matchExtern :: UnhandledMessagePolicy -> s -> ExternDispatcher s -> Match Message Source # matchMapExtern :: forall m s. UnhandledMessagePolicy -> s -> (Message -> m) -> ExternDispatcher s -> Match m Source # |
Message
type used internally by the call, cast, and rpcChan APIs.
Constructors
CastMessage a | |
CallMessage a (CallRef b) | |
ChanMessage a (SendPort b) |
Instances
data CallResponse a Source #
Response type for the call API
Constructors
CallResponse a CallId |
Instances
Serializable a => Binary (CallResponse a) Source # | |||||
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods put :: CallResponse a -> Put # get :: Get (CallResponse a) # putList :: [CallResponse a] -> Put # | |||||
NFSerializable a => NFData (CallResponse a) Source # | |||||
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods rnf :: CallResponse a -> () # | |||||
Generic (CallResponse a) Source # | |||||
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Associated Types
Methods from :: CallResponse a -> Rep (CallResponse a) x # to :: Rep (CallResponse a) x -> CallResponse a # | |||||
Show a => Show (CallResponse a) Source # | |||||
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods showsPrec :: Int -> CallResponse a -> ShowS # show :: CallResponse a -> String # showList :: [CallResponse a] -> ShowS # | |||||
Eq a => Eq (CallResponse a) Source # | |||||
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods (==) :: CallResponse a -> CallResponse a -> Bool # (/=) :: CallResponse a -> CallResponse a -> Bool # | |||||
type Rep (CallResponse a) Source # | |||||
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types type Rep (CallResponse a) = D1 ('MetaData "CallResponse" "Control.Distributed.Process.ManagedProcess.Internal.Types" "distributed-process-client-server-0.2.8.0-H0U1ekhkLkdwVNFuIdenK" 'False) (C1 ('MetaCons "CallResponse" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CallId))) |
type CallId = MonitorRef Source #
wrapper for a MonitorRef
Wraps a consumer of the call API
Instances
Binary (CallRef a) Source # | |||||
NFData (CallRef a) Source # | |||||
Resolvable (CallRef a) Source # | |||||
Routable (CallRef a) Source # | |||||
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods sendTo :: (Serializable m, Resolvable (CallRef a)) => CallRef a -> m -> Process () # unsafeSendTo :: (NFSerializable m, Resolvable (CallRef a)) => CallRef a -> m -> Process () # | |||||
Generic (CallRef a) Source # | |||||
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Associated Types
| |||||
Show (CallRef a) Source # | |||||
Eq (CallRef a) Source # | |||||
type Rep (CallRef a) Source # | |||||
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types type Rep (CallRef a) = D1 ('MetaData "CallRef" "Control.Distributed.Process.ManagedProcess.Internal.Types" "distributed-process-client-server-0.2.8.0-H0U1ekhkLkdwVNFuIdenK" 'True) (C1 ('MetaCons "CallRef" 'PrefixI 'True) (S1 ('MetaSel ('Just "unCaller") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Recipient, CallId)))) |
data CallRejected Source #
Sent to a consumer of the call API when a server filter expression explicitly rejects an incoming call message.
Constructors
CallRejected String CallId |
Instances
Binary CallRejected Source # | |||||
NFData CallRejected Source # | |||||
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods rnf :: CallRejected -> () # | |||||
Generic CallRejected Source # | |||||
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Associated Types
| |||||
Show CallRejected Source # | |||||
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types Methods showsPrec :: Int -> CallRejected -> ShowS # show :: CallRejected -> String # showList :: [CallRejected] -> ShowS # | |||||
Eq CallRejected Source # | |||||
type Rep CallRejected Source # | |||||
Defined in Control.Distributed.Process.ManagedProcess.Internal.Types type Rep CallRejected = D1 ('MetaData "CallRejected" "Control.Distributed.Process.ManagedProcess.Internal.Types" "distributed-process-client-server-0.2.8.0-H0U1ekhkLkdwVNFuIdenK" 'False) (C1 ('MetaCons "CallRejected" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CallId))) |
makeRef :: Recipient -> CallId -> CallRef a Source #
Creates a CallRef
for the given Recipient
and CallId
caller :: Message a b -> Maybe Recipient Source #
Retrieve the Recipient
from a Message
. If the supplied message is
a cast or chan message will evaluate to Nothing
, otherwise Just ref
.
rejectToCaller :: Message a b -> String -> Process () Source #
Reject a call message with the supplied string. Sends CallRejected
to
the recipient if the input is a CallMessage
, otherwise has no side effects.
initCall :: (Addressable s, Serializable a, Serializable b) => s -> a -> Process (CallRef b) Source #
The send part of the call client-server interaction. The resulting CallRef can be used to identify the corrolary response message (if one is sent by the server), and is unique to this call-reply pair.
unsafeInitCall :: (Addressable s, NFSerializable a, NFSerializable b) => s -> a -> Process (CallRef b) Source #
Version of initCall
that utilises "unsafeSendTo".
waitResponse :: Serializable b => Maybe TimeInterval -> CallRef b -> Process (Maybe (Either ExitReason b)) Source #
Wait on the server's response after an "initCall" has been previously been sent.
This function does not trap asynchronous exceptions.