Safe Haskell | None |
---|---|
Language | Haskell2010 |
System.ZMQ4.Patterns.Clone.Internal
Synopsis
- data Message a = Message {
- messageVersion :: !Word64
- messageValue :: !a
- iSTATE_REQUEST :: ByteString
- publisher :: Binary a => String -> String -> MVar a -> IO ()
- subscriber :: Binary a => String -> String -> MVar a -> IO ()
- queryLastState :: Binary a => String -> IO a
Shared
Actual message sent between server and client.
Constructors
Message | |
Fields
|
iSTATE_REQUEST :: ByteString Source #
Message sent by a client to request a state snapshot
Server
Arguments
:: Binary a | |
=> String | Bind address of the PUB socket |
-> String | Bind address of the ROUTER socket |
-> MVar a | Channel of incoming messages |
-> IO () |
A server publishing messages to a client.
This function will start serving messages on the current thread.
It will send all objects that are pushed on the channel to a PUB socket.
It will listen for snapshot requests on a ROUTER socket.
The server will automatically keep the last sent
object cached, and use at as a snapshot. Sequencing
is automatically handled using a Word64
sequence
counter.
Client
Arguments
:: Binary a | |
=> String | Address of the server's PUB socket |
-> String | Address of the server's ROUTER socket |
-> MVar a | CHannel where incoming messsages will be written to |
-> IO () |
A client receiving messages from a server.
This function will start reading messages on the current thread.
It will connect to the server's PUB and ROUTER ports. It will backlog messages from the PUB socket, while requesting the initial state snapshot from the ROUTER socket. Afterwards, it will forever read from the PUB socket, and process all in-sequence updates.
Note that this pattern is not 100% reliable. Messages might be dropped between the initial state request and the first update.