Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | Toralf Wittner <tw@dtex.org> |
Safe Haskell | None |
System.ZMQ3.Monadic
Contents
Description
- data ZMQ z a
- data Socket z t
- data Flag = SendMore
- data Switch
- type Timeout = Int64
- data Event
- data EventType
- data EventMsg
- = Connected !ByteString !Fd
- | ConnectDelayed !ByteString !Fd
- | ConnectRetried !ByteString !Int
- | Listening !ByteString !Fd
- | BindFailed !ByteString !Fd
- | Accepted !ByteString !Fd
- | AcceptFailed !ByteString !Int
- | Closed !ByteString !Fd
- | CloseFailed !ByteString !Int
- | Disconnected !ByteString !Int
- data Poll m where
- class SocketType a
- class Sender a
- class Receiver a
- class Subscriber a
- data Pair = Pair
- data Pub = Pub
- data Sub = Sub
- data XPub = XPub
- data XSub = XSub
- data Req = Req
- data Rep = Rep
- data Dealer = Dealer
- data Router = Router
- data Pull = Pull
- data Push = Push
- version :: ZMQ z (Int, Int, Int)
- runZMQ :: MonadIO m => (forall z. ZMQ z a) -> m a
- async :: ZMQ z a -> ZMQ z (Async a)
- socket :: SocketType t => t -> ZMQ z (Socket z t)
- ioThreads :: ZMQ z Word
- maxSockets :: ZMQ z Word
- setIoThreads :: Word -> ZMQ z ()
- setMaxSockets :: Word -> ZMQ z ()
- close :: Socket z t -> ZMQ z ()
- bind :: Socket z t -> String -> ZMQ z ()
- unbind :: Socket z t -> String -> ZMQ z ()
- connect :: Socket z t -> String -> ZMQ z ()
- send :: Sender t => Socket z t -> [Flag] -> ByteString -> ZMQ z ()
- send' :: Sender t => Socket z t -> [Flag] -> ByteString -> ZMQ z ()
- sendMulti :: Sender t => Socket z t -> NonEmpty ByteString -> ZMQ z ()
- receive :: Receiver t => Socket z t -> ZMQ z ByteString
- receiveMulti :: Receiver t => Socket z t -> ZMQ z [ByteString]
- subscribe :: Subscriber t => Socket z t -> ByteString -> ZMQ z ()
- unsubscribe :: Subscriber t => Socket z t -> ByteString -> ZMQ z ()
- proxy :: Socket z a -> Socket z b -> Maybe (Socket z c) -> ZMQ z ()
- monitor :: [EventType] -> Socket z t -> ZMQ z (Bool -> IO (Maybe EventMsg))
- poll :: MonadIO m => Timeout -> [Poll m] -> m [[Event]]
- affinity :: Socket z t -> ZMQ z Word64
- backlog :: Socket z t -> ZMQ z Int
- delayAttachOnConnect :: Socket z t -> ZMQ z Bool
- events :: Socket z t -> ZMQ z [Event]
- fileDescriptor :: Socket z t -> ZMQ z Fd
- identity :: Socket z t -> ZMQ z ByteString
- ipv4Only :: Socket z t -> ZMQ z Bool
- lastEndpoint :: Socket z t -> ZMQ z String
- linger :: Socket z t -> ZMQ z Int
- maxMessageSize :: Socket z t -> ZMQ z Int64
- mcastHops :: Socket z t -> ZMQ z Int
- moreToReceive :: Socket z t -> ZMQ z Bool
- rate :: Socket z t -> ZMQ z Int
- receiveBuffer :: Socket z t -> ZMQ z Int
- receiveHighWM :: Socket z t -> ZMQ z Int
- receiveTimeout :: Socket z t -> ZMQ z Int
- reconnectInterval :: Socket z t -> ZMQ z Int
- reconnectIntervalMax :: Socket z t -> ZMQ z Int
- recoveryInterval :: Socket z t -> ZMQ z Int
- sendBuffer :: Socket z t -> ZMQ z Int
- sendHighWM :: Socket z t -> ZMQ z Int
- sendTimeout :: Socket z t -> ZMQ z Int
- tcpKeepAlive :: Socket z t -> ZMQ z Switch
- tcpKeepAliveCount :: Socket z t -> ZMQ z Int
- tcpKeepAliveIdle :: Socket z t -> ZMQ z Int
- tcpKeepAliveInterval :: Socket z t -> ZMQ z Int
- setAffinity :: Word64 -> Socket z t -> ZMQ z ()
- setBacklog :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()
- setDelayAttachOnConnect :: Bool -> Socket z t -> ZMQ z ()
- setIdentity :: Restricted N1 N254 ByteString -> Socket z t -> ZMQ z ()
- setIpv4Only :: Bool -> Socket z t -> ZMQ z ()
- setLinger :: Integral i => Restricted Nneg1 Int32 i -> Socket z t -> ZMQ z ()
- setMaxMessageSize :: Integral i => Restricted Nneg1 Int64 i -> Socket z t -> ZMQ z ()
- setMcastHops :: Integral i => Restricted N1 Int32 i -> Socket z t -> ZMQ z ()
- setRate :: Integral i => Restricted N1 Int32 i -> Socket z t -> ZMQ z ()
- setReceiveBuffer :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()
- setReceiveHighWM :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()
- setReceiveTimeout :: Integral i => Restricted Nneg1 Int32 i -> Socket z t -> ZMQ z ()
- setReconnectInterval :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()
- setReconnectIntervalMax :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()
- setRecoveryInterval :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()
- setRouterMandatory :: Bool -> Socket z Router -> ZMQ z ()
- setSendBuffer :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()
- setSendHighWM :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()
- setSendTimeout :: Integral i => Restricted Nneg1 Int32 i -> Socket z t -> ZMQ z ()
- setTcpAcceptFilter :: Maybe ByteString -> Socket z t -> ZMQ z ()
- setTcpKeepAlive :: Switch -> Socket z t -> ZMQ z ()
- setTcpKeepAliveCount :: Integral i => Restricted Nneg1 Int32 i -> Socket z t -> ZMQ z ()
- setTcpKeepAliveIdle :: Integral i => Restricted Nneg1 Int32 i -> Socket z t -> ZMQ z ()
- setTcpKeepAliveInterval :: Integral i => Restricted Nneg1 Int32 i -> Socket z t -> ZMQ z ()
- setXPubVerbose :: Bool -> Socket z XPub -> ZMQ z ()
- data ZMQError
- errno :: ZMQError -> Int
- source :: ZMQError -> String
- message :: ZMQError -> String
- liftIO :: MonadIO m => forall a. IO a -> m a
- restrict :: Restriction l u v => v -> Restricted l u v
- toRestricted :: Restriction l u v => v -> Maybe (Restricted l u v)
- waitRead :: Socket z t -> ZMQ z ()
- waitWrite :: Socket z t -> ZMQ z ()
Type Definitions
The ZMQ monad is modeled after ST
and encapsulates
a Context
. It uses the uninstantiated type variable z
to
distinguish different invoctions of runZMQ
and to prevent
unintented use of Socket
s outside their scope. Cf. the paper
of John Launchbury and Simon Peyton Jones Lazy Functional State Threads.
Instances
Monad (ZMQ z) | |
Functor (ZMQ z) | |
Applicative (ZMQ z) | |
MonadCatchIO (ZMQ z) | |
MonadIO (ZMQ z) |
The ZMQ socket, parameterised by SocketType
and belonging to
a particular ZMQ
thread.
Flags to apply on send operations (cf. man zmq_send)
Constructors
SendMore | ZMQ_SNDMORE |
Configuration switch
Socket events.
Event types to monitor.
Event Message to receive when monitoring socket events.
Constructors
Type representing a descriptor, poll is waiting for (either a 0MQ socket or a file descriptor) plus the type of event to wait for.
Type Classes
class SocketType a Source
Socket types.
Sockets which can send
.
Sockets which can receive
.
Socket Types
Socket to communicate with a single peer. Allows for only a
single connect or a single bind. There's no message routing
or message filtering involved. Compatible peer sockets: Pair
.
Constructors
Pair |
Socket to distribute data. receive
function is not
implemented for this socket type. Messages are distributed in
fanout fashion to all the peers. Compatible peer sockets: Sub
.
Constructors
Pub |
Instances
Socket to subscribe for data. send
function is not implemented
for this socket type. Initially, socket is subscribed for no
messages. Use subscribe
to specify which messages to subscribe for.
Compatible peer sockets: Pub
.
Constructors
Sub |
Instances
Same as Pub
except that you can receive subscriptions from the
peers in form of incoming messages. Subscription message is a byte 1
(for subscriptions) or byte 0 (for unsubscriptions) followed by the
subscription body.
Compatible peer sockets: Sub
, XSub
.
Constructors
XPub |
Same as Sub
except that you subscribe by sending subscription
messages to the socket. Subscription message is a byte 1 (for subscriptions)
or byte 0 (for unsubscriptions) followed by the subscription body.
Compatible peer sockets: Pub
, XPub
.
Constructors
XSub |
Socket to send requests and receive replies. Requests are
load-balanced among all the peers. This socket type allows only an
alternated sequence of send's and recv's.
Compatible peer sockets: Rep
, Router
.
Constructors
Req |
Socket to receive requests and send replies. This socket type
allows only an alternated sequence of receive's and send's. Each
send is routed to the peer that issued the last received request.
Compatible peer sockets: Req
, Dealer
.
Constructors
Rep |
Each message sent is round-robined among all connected peers,
and each message received is fair-queued from all connected peers.
Compatible peer sockets: Router
, Req
, Rep
.
Constructors
Dealer |
When receiving messages a Router socket shall prepend a message
part containing the identity of the originating peer to
the message before passing it to the application. Messages
received are fair-queued from among all connected peers. When
sending messages a Router socket shall remove the first part of
the message and use it to determine the identity of the peer the
message shall be routed to. If the peer does not exist anymore
the message shall be silently discarded.
Compatible peer sockets: Dealer
, Req
, Rep
.
Constructors
Router |
A socket of type Pull is used by a pipeline node to receive messages from upstream pipeline nodes. Messages are fair-queued from among all connected upstream nodes. The zmq_send() function is not implemented for this socket type.
Constructors
Pull |
Instances
A socket of type Push is used by a pipeline node to send messages to downstream pipeline nodes. Messages are load-balanced to all connected downstream nodes. The zmq_recv() function is not implemented for this socket type.
When a Push socket enters an exceptional state due to having reached the high water mark for all downstream nodes, or if there are no downstream nodes at all, then any zmq_send(3) operations on the socket shall block until the exceptional state ends or at least one downstream node becomes available for sending; messages are not discarded.
Constructors
Push |
Instances
General Operations
async :: ZMQ z a -> ZMQ z (Async a)Source
Run the given ZMQ
computation asynchronously, i.e. this function
runs the computation in a new thread using async
.
N.B. reference counting is used to prolong the lifetime of the
Context
encapsulated in ZMQ
as necessary, e.g.:
runZMQ $ do s <- socket Pair async $ do liftIO (threadDelay 10000000) identity s >>= liftIO . print
Here, runZMQ
will finish before the code section in async
, but due to
reference counting, the Context
will only be disposed after
async
finishes as well.
socket :: SocketType t => t -> ZMQ z (Socket z t)Source
ZMQ Options (Read)
maxSockets :: ZMQ z WordSource
ZMQ Options (Write)
setIoThreads :: Word -> ZMQ z ()Source
setMaxSockets :: Word -> ZMQ z ()Source
Socket operations
receiveMulti :: Receiver t => Socket z t -> ZMQ z [ByteString]Source
subscribe :: Subscriber t => Socket z t -> ByteString -> ZMQ z ()Source
unsubscribe :: Subscriber t => Socket z t -> ByteString -> ZMQ z ()Source
Socket Options (Read)
delayAttachOnConnect :: Socket z t -> ZMQ z BoolSource
fileDescriptor :: Socket z t -> ZMQ z FdSource
identity :: Socket z t -> ZMQ z ByteStringSource
lastEndpoint :: Socket z t -> ZMQ z StringSource
maxMessageSize :: Socket z t -> ZMQ z Int64Source
moreToReceive :: Socket z t -> ZMQ z BoolSource
receiveBuffer :: Socket z t -> ZMQ z IntSource
receiveHighWM :: Socket z t -> ZMQ z IntSource
receiveTimeout :: Socket z t -> ZMQ z IntSource
reconnectInterval :: Socket z t -> ZMQ z IntSource
reconnectIntervalMax :: Socket z t -> ZMQ z IntSource
recoveryInterval :: Socket z t -> ZMQ z IntSource
sendBuffer :: Socket z t -> ZMQ z IntSource
sendHighWM :: Socket z t -> ZMQ z IntSource
sendTimeout :: Socket z t -> ZMQ z IntSource
tcpKeepAlive :: Socket z t -> ZMQ z SwitchSource
tcpKeepAliveCount :: Socket z t -> ZMQ z IntSource
tcpKeepAliveIdle :: Socket z t -> ZMQ z IntSource
tcpKeepAliveInterval :: Socket z t -> ZMQ z IntSource
Socket Options (Write)
setAffinity :: Word64 -> Socket z t -> ZMQ z ()Source
setBacklog :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()Source
setDelayAttachOnConnect :: Bool -> Socket z t -> ZMQ z ()Source
setIdentity :: Restricted N1 N254 ByteString -> Socket z t -> ZMQ z ()Source
setIpv4Only :: Bool -> Socket z t -> ZMQ z ()Source
setMaxMessageSize :: Integral i => Restricted Nneg1 Int64 i -> Socket z t -> ZMQ z ()Source
setMcastHops :: Integral i => Restricted N1 Int32 i -> Socket z t -> ZMQ z ()Source
setReceiveBuffer :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()Source
setReceiveHighWM :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()Source
setReceiveTimeout :: Integral i => Restricted Nneg1 Int32 i -> Socket z t -> ZMQ z ()Source
setReconnectInterval :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()Source
setReconnectIntervalMax :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()Source
setRecoveryInterval :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()Source
setSendBuffer :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()Source
setSendHighWM :: Integral i => Restricted N0 Int32 i -> Socket z t -> ZMQ z ()Source
setSendTimeout :: Integral i => Restricted Nneg1 Int32 i -> Socket z t -> ZMQ z ()Source
setTcpAcceptFilter :: Maybe ByteString -> Socket z t -> ZMQ z ()Source
setTcpKeepAlive :: Switch -> Socket z t -> ZMQ z ()Source
setTcpKeepAliveCount :: Integral i => Restricted Nneg1 Int32 i -> Socket z t -> ZMQ z ()Source
setTcpKeepAliveIdle :: Integral i => Restricted Nneg1 Int32 i -> Socket z t -> ZMQ z ()Source
setTcpKeepAliveInterval :: Integral i => Restricted Nneg1 Int32 i -> Socket z t -> ZMQ z ()Source
Error Handling
ZMQError encapsulates information about errors, which occur when using the native 0MQ API, such as error number and message.
Re-exports
restrict :: Restriction l u v => v -> Restricted l u vSource
Create a restricted value. If the given value does not satisfy the restrictions, a modified variant is used instead, e.g. if an integer is larger than the upper bound, the upper bound value is used.
toRestricted :: Restriction l u v => v -> Maybe (Restricted l u v)Source
Create a restricted value. Returns Nothing
if
the given value does not satisfy all restrictions.