-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Execution Framework for The Cloud Haskell Application Platform -- -- The Execution Framework provides tools for load regulation, workload -- shedding and remote hand-off. The currently implementation provides -- only a subset of the plumbing required, comprising tools for event -- management, mailbox buffering and message routing. @package distributed-process-execution @version 0.1.3.0 -- |
-- is <- broadcastClient ex -- msg <- receiveWait [ matchInputStream is ] -- handleMessage (payload msg) --broadcastClient :: Exchange -> Process (InputStream Message) -- | Bind the calling process to the given broadcast exchange. For -- each Message the exchange receives, only the payload will be -- sent to the calling process' mailbox. -- -- Example: -- -- (producer) > post ex Hello -- -- (consumer) > bindToBroadcaster ex > expect >>= liftIO . -- putStrLn bindToBroadcaster :: Exchange -> Process () type BroadcastExchange = ExchangeType BroadcastEx type HeaderName = String -- | The binding key used by the built-in key and header based routers. data Binding BindKey :: !String -> Binding [bindingKey] :: Binding -> !String BindHeader :: !String -> !HeaderName -> Binding [bindingKey] :: Binding -> !String [headerName] :: Binding -> !HeaderName BindNone :: Binding -- | Things that can be used as binding keys in a router. class (Hashable k, Eq k, Serializable k) => Bindable k -- | Used to convert a Message into a Bindable routing key. type BindingSelector k = (Message -> Process k) -- | Given to a router to indicate whether clients should receive -- Message payloads only, or the whole Message object -- itself. data RelayType PayloadOnly :: RelayType WholeMessage :: RelayType -- | Defines a router exchange. The BindingSelector is used -- to construct a binding (i.e., an instance of the Bindable type -- k) for each incoming Message. Such bindings are -- matched against bindings stored in the exchange. Clients of a -- router exchange are identified by a binding, mapped to one or -- more ProcessIds. -- -- The format of the bindings, nature of their storage and mechanism for -- submitting new bindings is implementation dependent (i.e., will vary -- by exchange type). For example, the messageKeyRouter and -- headerContentRouter implementations both use the Binding -- data type, which can represent a Message key or a -- HeaderName and content. As with all custom exchange types, -- bindings should be submitted by evaluating configureExchange -- with a suitable data type. router :: Bindable k => RelayType -> BindingSelector k -> Process Exchange -- | Defines a router that can be used in a supervision tree. supervisedRouter :: Bindable k => RelayType -> BindingSelector k -> SupervisorPid -> Process Exchange -- | Send a Serializable message to the supplied Exchange. -- The given datum will be converted to a Message, with the -- key set to "" and the headers to []. -- -- The routing behaviour will be dependent on the choice of -- BindingSelector given when initialising the router. route :: Serializable m => Exchange -> m -> Process () -- | Send a Message to the supplied Exchange. The routing -- behaviour will be dependent on the choice of BindingSelector -- given when initialising the router. routeMessage :: Exchange -> Message -> Process () -- | A router that matches on a Message key. To bind a client -- Process to such an exchange, use the bindKey function. messageKeyRouter :: RelayType -> Process Exchange -- | Add a binding (for the calling process) to a messageKeyRouter -- exchange. bindKey :: String -> Exchange -> Process () -- | A router that matches on a specific (named) header. To bind a client -- Process to such an exchange, use the bindHeader -- function. headerContentRouter :: RelayType -> HeaderName -> Process Exchange -- | Add a binding (for the calling process) to a -- headerContentRouter exchange. bindHeader :: HeaderName -> String -> Exchange -> Process () -- | Different exchange types are defined using record syntax. The -- configureEx and routeEx API functions are called during -- the exchange lifecycle when incoming traffic arrives. Configuration -- messages are completely arbitrary types and the exchange type author -- is entirely responsible for decoding them. Messages posted to the -- exchange (see the Message data type) are passed to the -- routeEx API function along with the exchange type's own -- internal state. Both API functions return a new (potentially updated) -- state and run in the Process monad. data ExchangeType s ExchangeType :: String -> s -> (s -> Message -> Process s) -> (s -> Message -> Process s) -> ExchangeType s [name] :: ExchangeType s -> String [state] :: ExchangeType s -> s [configureEx] :: ExchangeType s -> s -> Message -> Process s [routeEx] :: ExchangeType s -> s -> Message -> Process s -- | Utility for custom exchange type authors - evaluates a set of -- primitive message handlers from left to right, returning the first -- which evaluates to Just a, or the initial e value if -- all the handlers yield Nothing. applyHandlers :: a -> Message -> [Message -> Process (Maybe a)] -> Process a -- |
-- start = spawnLocal $ run --startMailbox :: ProcessId -> BufferType -> Limit -> Process Mailbox -- | As startMailbox, but suitable for use in supervisor child -- specs. This variant is for use when you want to access to the -- underlying Mailbox handle in your supervised child refs. See -- supervisor's ChildRef data type for more information. -- -- Example: > childSpec = toChildStart $ startSupervised pid -- bufferType mboxLimit -- -- See Control.Distributed.Process.Supervisor startSupervised :: ProcessId -> BufferType -> Limit -> SupervisorPid -> Process (ProcessId, Message) -- | As startMailbox, but suitable for use in supervisor child -- specs. -- -- See Control.Distributed.Process.Supervisor startSupervisedMailbox :: ProcessId -> BufferType -> Limit -> SupervisorPid -> Process Mailbox -- | Start a mailbox for the calling process. -- --
-- create = getSelfPid >>= start --createMailbox :: BufferType -> Limit -> Process Mailbox -- | Alters the mailbox's limit - this might cause messages to be -- dropped! resize :: Mailbox -> Integer -> Process () -- | Obtain statistics (from/to anywhere) about a mailbox. statistics :: Mailbox -> Process MailboxStats -- | Monitor a mailbox. monitor :: Mailbox -> Process MonitorRef -- | Represents the maximum number of messages the internal buffer can -- hold. type Limit = Integer -- | Describes the different types of buffer. data BufferType -- | FIFO buffer, limiter drops the eldest message (queue head) Queue :: BufferType -- | unordered buffer, limiter drops the newest (top) message Stack :: BufferType -- | FIFO buffer, limiter refuses (i.e., drops) new messages Ring :: BufferType -- | Bundle of statistics data, available on request via the -- mailboxStats API call. data MailboxStats MailboxStats :: Integer -> Integer -> Limit -> ProcessId -> MailboxStats [pendingMessages] :: MailboxStats -> Integer [droppedMessages] :: MailboxStats -> Integer [currentLimit] :: MailboxStats -> Limit [owningProcess] :: MailboxStats -> ProcessId -- | Posts a message to someone's mailbox. post :: Serializable a => Mailbox -> a -> Process () -- | Instructs the mailbox to send a NewMail signal as soon as any -- mail is available for delivery. Once the signal is sent, it will not -- be resent, even when further mail arrives, until notify is -- called again. -- -- NB: signals are only delivered to the mailbox's owning process. notify :: Mailbox -> Process () -- | Instructs the mailbox to deliver all pending messages to the owner. deliver :: Mailbox -> Process () -- | Instructs the mailbox to send a Delivery as soon as any mail is -- available, or immediately (if the buffer already contains data). -- -- NB: signals are only delivered to the mailbox's owning process. active :: Mailbox -> Filter -> Process () -- | Marker message indicating to the owning process that mail has arrived. data NewMail NewMail :: !Mailbox -> !Integer -> NewMail -- | Mail delivery. data Delivery Delivery :: Mailbox -> [Message] -> Integer -> Integer -> Delivery -- | handle to the sending mailbox [box] :: Delivery -> Mailbox -- | list of raw messages [messages] :: Delivery -> [Message] -- | number of messages delivered [count] :: Delivery -> Integer -- | total dropped/skipped messages [totalDropped] :: Delivery -> Integer data FilterResult Keep :: FilterResult Skip :: FilterResult Send :: FilterResult -- | A do-nothing filter that accepts all messages (i.e., returns -- Keep for any input). acceptEverything :: Closure (Message -> Process FilterResult) -- | A filter that takes a Closure (Message -> Process -- FilterResult) holding the filter function and applies it remotely -- (i.e., in the mailbox's own managed process). acceptMatching :: Closure (Closure (Message -> Process FilterResult) -> Message -> Process FilterResult) __remoteTable :: RemoteTable -> RemoteTable instance GHC.Show.Show Control.Distributed.Process.Execution.Mailbox.BufferType instance GHC.Classes.Eq Control.Distributed.Process.Execution.Mailbox.BufferType instance GHC.Show.Show Control.Distributed.Process.Execution.Mailbox.MailboxStats instance GHC.Generics.Generic Control.Distributed.Process.Execution.Mailbox.MailboxStats instance GHC.Generics.Generic Control.Distributed.Process.Execution.Mailbox.Post instance GHC.Generics.Generic Control.Distributed.Process.Execution.Mailbox.StatsReq instance GHC.Generics.Generic Control.Distributed.Process.Execution.Mailbox.FilterResult instance GHC.Generics.Generic Control.Distributed.Process.Execution.Mailbox.Mode instance GHC.Generics.Generic Control.Distributed.Process.Execution.Mailbox.ControlMessage instance GHC.Classes.Eq Control.Distributed.Process.Execution.Mailbox.Mailbox instance GHC.Generics.Generic Control.Distributed.Process.Execution.Mailbox.Mailbox instance GHC.Generics.Generic Control.Distributed.Process.Execution.Mailbox.Delivery instance GHC.Show.Show Control.Distributed.Process.Execution.Mailbox.NewMail instance GHC.Generics.Generic Control.Distributed.Process.Execution.Mailbox.NewMail instance Control.Distributed.Process.Execution.Mailbox.Buffered Control.Distributed.Process.Execution.Mailbox.State instance Data.Binary.Class.Binary Control.Distributed.Process.Execution.Mailbox.NewMail instance Data.Binary.Class.Binary Control.Distributed.Process.Execution.Mailbox.Delivery instance Data.Binary.Class.Binary Control.Distributed.Process.Execution.Mailbox.Mailbox instance GHC.Show.Show Control.Distributed.Process.Execution.Mailbox.Mailbox instance Control.Distributed.Process.Extras.Internal.Types.Linkable Control.Distributed.Process.Execution.Mailbox.Mailbox instance Control.Distributed.Process.Extras.Internal.Types.Resolvable Control.Distributed.Process.Execution.Mailbox.Mailbox instance Control.Distributed.Process.Extras.Internal.Types.Routable Control.Distributed.Process.Execution.Mailbox.Mailbox instance Control.Distributed.Process.Extras.Internal.Types.Addressable Control.Distributed.Process.Execution.Mailbox.Mailbox instance Data.Binary.Class.Binary Control.Distributed.Process.Execution.Mailbox.ControlMessage instance Data.Binary.Class.Binary Control.Distributed.Process.Execution.Mailbox.Mode instance GHC.Show.Show Control.Distributed.Process.Execution.Mailbox.Mode instance Data.Binary.Class.Binary Control.Distributed.Process.Execution.Mailbox.FilterResult instance Data.Binary.Class.Binary Control.Distributed.Process.Execution.Mailbox.StatsReq instance Data.Binary.Class.Binary Control.Distributed.Process.Execution.Mailbox.Post instance Data.Binary.Class.Binary Control.Distributed.Process.Execution.Mailbox.MailboxStats -- |
-- start = spawnLocal $ run --startMailbox :: ProcessId -> BufferType -> Limit -> Process Mailbox -- | As startMailbox, but suitable for use in supervisor child -- specs. -- -- See Control.Distributed.Process.Supervisor startSupervisedMailbox :: ProcessId -> BufferType -> Limit -> SupervisorPid -> Process Mailbox -- | Start a mailbox for the calling process. -- --
-- create = getSelfPid >>= start --createMailbox :: BufferType -> Limit -> Process Mailbox -- | Alters the mailbox's limit - this might cause messages to be -- dropped! resize :: Mailbox -> Integer -> Process () -- | Instructs the mailbox to send a Delivery as soon as any mail is -- available, or immediately (if the buffer already contains data). -- -- NB: signals are only delivered to the mailbox's owning process. active :: Mailbox -> Filter -> Process () -- | A do-nothing filter that accepts all messages (i.e., returns -- Keep for any input). acceptEverything :: Closure (Message -> Process FilterResult) -- | A filter that takes a Closure (Message -> Process -- FilterResult) holding the filter function and applies it remotely -- (i.e., in the mailbox's own managed process). acceptMatching :: Closure (Closure (Message -> Process FilterResult) -> Message -> Process FilterResult) -- | Messages sent to an exchange can optionally provide a routing key and -- a list of (key, value) headers in addition to the underlying payload. data Message Message :: !String -> ![(String, String)] -> !Message -> Message -- | a routing key for the payload [key] :: Message -> !String -- | arbitrary key-value headers [headers] :: Message -> ![(String, String)] -- | the underlying Message payload [payload] :: Message -> !Message -- | Opaque handle to an exchange. data Exchange type BroadcastExchange = ExchangeType BroadcastEx type HeaderName = String -- | The binding key used by the built-in key and header based routers. data Binding BindKey :: !String -> Binding [bindingKey] :: Binding -> !String BindHeader :: !String -> !HeaderName -> Binding [bindingKey] :: Binding -> !String [headerName] :: Binding -> !HeaderName BindNone :: Binding -- | Things that can be used as binding keys in a router. class (Hashable k, Eq k, Serializable k) => Bindable k -- | Used to convert a Message into a Bindable routing key. type BindingSelector k = (Message -> Process k) -- | Given to a router to indicate whether clients should receive -- Message payloads only, or the whole Message object -- itself. data RelayType PayloadOnly :: RelayType WholeMessage :: RelayType -- | Different exchange types are defined using record syntax. The -- configureEx and routeEx API functions are called during -- the exchange lifecycle when incoming traffic arrives. Configuration -- messages are completely arbitrary types and the exchange type author -- is entirely responsible for decoding them. Messages posted to the -- exchange (see the Message data type) are passed to the -- routeEx API function along with the exchange type's own -- internal state. Both API functions return a new (potentially updated) -- state and run in the Process monad. data ExchangeType s ExchangeType :: String -> s -> (s -> Message -> Process s) -> (s -> Message -> Process s) -> ExchangeType s [name] :: ExchangeType s -> String [state] :: ExchangeType s -> s [configureEx] :: ExchangeType s -> s -> Message -> Process s [routeEx] :: ExchangeType s -> s -> Message -> Process s -- | Utility for creating a Message datum from its key, -- headers and payload. createMessage :: Serializable m => String -> [(String, String)] -> m -> Message -- | Posts an arbitrary Serializable datum to an exchange. -- The raw datum is wrapped in the Message data type, with its -- key set to "" and its headers to []. post :: Serializable a => Exchange -> a -> Process () -- | Starts an exchange as part of a supervision tree. -- -- Example: > childSpec = toChildStart $ startSupervisedRef exType startSupervisedRef :: forall s. ExchangeType s -> SupervisorPid -> Process (ProcessId, Message) -- | Start a new broadcast exchange and return a handle to the -- exchange. broadcastExchange :: Process Exchange -- | The ExchangeType of a broadcast exchange. Can be combined with -- the startSupervisedRef and startSupervised APIs. broadcastExchangeT :: Process BroadcastExchange -- | Create a binding to the given broadcast exchange for the -- calling process and return an InputStream that can be used in -- the expect and receiveWait family of messaging -- primitives. This form of client interaction helps avoid cluttering the -- caller's mailbox with Message data, since the -- InputChannel provides a separate input stream (in a similar -- fashion to a typed channel). Example: -- --
-- is <- broadcastClient ex -- msg <- receiveWait [ matchInputStream is ] -- handleMessage (payload msg) --broadcastClient :: Exchange -> Process (InputStream Message) -- | Starts an exchange process with the given ExchangeType. startExchange :: forall s. ExchangeType s -> Process Exchange runExchange :: forall s. ExchangeType s -> MVar (ControlPort ControlMessage) -> Process () -- | Posts a Message to an exchange. postMessage :: Exchange -> Message -> Process () -- | Sends an arbitrary Serializable datum to an exchange, -- for use as a configuration change - see configureEx for -- details. configureExchange :: Serializable m => Exchange -> m -> Process () -- | Bind the calling process to the given broadcast exchange. For -- each Message the exchange receives, only the payload will be -- sent to the calling process' mailbox. -- -- Example: -- -- (producer) > post ex Hello -- -- (consumer) > bindToBroadcaster ex > expect >>= liftIO . -- putStrLn bindToBroadcaster :: Exchange -> Process () -- | Defines a router exchange. The BindingSelector is used -- to construct a binding (i.e., an instance of the Bindable type -- k) for each incoming Message. Such bindings are -- matched against bindings stored in the exchange. Clients of a -- router exchange are identified by a binding, mapped to one or -- more ProcessIds. -- -- The format of the bindings, nature of their storage and mechanism for -- submitting new bindings is implementation dependent (i.e., will vary -- by exchange type). For example, the messageKeyRouter and -- headerContentRouter implementations both use the Binding -- data type, which can represent a Message key or a -- HeaderName and content. As with all custom exchange types, -- bindings should be submitted by evaluating configureExchange -- with a suitable data type. router :: Bindable k => RelayType -> BindingSelector k -> Process Exchange -- | Defines a router that can be used in a supervision tree. supervisedRouter :: Bindable k => RelayType -> BindingSelector k -> SupervisorPid -> Process Exchange -- | Send a Serializable message to the supplied Exchange. -- The given datum will be converted to a Message, with the -- key set to "" and the headers to []. -- -- The routing behaviour will be dependent on the choice of -- BindingSelector given when initialising the router. route :: Serializable m => Exchange -> m -> Process () -- | Send a Message to the supplied Exchange. The routing -- behaviour will be dependent on the choice of BindingSelector -- given when initialising the router. routeMessage :: Exchange -> Message -> Process () -- | A router that matches on a Message key. To bind a client -- Process to such an exchange, use the bindKey function. messageKeyRouter :: RelayType -> Process Exchange -- | Add a binding (for the calling process) to a messageKeyRouter -- exchange. bindKey :: String -> Exchange -> Process () -- | A router that matches on a specific (named) header. To bind a client -- Process to such an exchange, use the bindHeader -- function. headerContentRouter :: RelayType -> HeaderName -> Process Exchange -- | Add a binding (for the calling process) to a -- headerContentRouter exchange. bindHeader :: HeaderName -> String -> Exchange -> Process () -- | Utility for custom exchange type authors - evaluates a set of -- primitive message handlers from left to right, returning the first -- which evaluates to Just a, or the initial e value if -- all the handlers yield Nothing. applyHandlers :: a -> Message -> [Message -> Process (Maybe a)] -> Process a