zeromq4-patterns-0.3.1.0: Haskell implementation of several ZeroMQ patterns.

Safe HaskellNone
LanguageHaskell2010

System.ZMQ4.Patterns.Clone.Internal

Contents

Synopsis

Shared

data Message a #

Actual message sent between server and client.

Constructors

Message 
Instances
Eq a => Eq (Message a) # 
Instance details

Defined in System.ZMQ4.Patterns.Clone.Internal

Methods

(==) :: Message a -> Message a -> Bool #

(/=) :: Message a -> Message a -> Bool #

Show a => Show (Message a) # 
Instance details

Defined in System.ZMQ4.Patterns.Clone.Internal

Methods

showsPrec :: Int -> Message a -> ShowS #

show :: Message a -> String #

showList :: [Message a] -> ShowS #

Binary a => Binary (Message a) # 
Instance details

Defined in System.ZMQ4.Patterns.Clone.Internal

Methods

put :: Message a -> Put #

get :: Get (Message a) #

putList :: [Message a] -> Put #

iSTATE_REQUEST :: ByteString #

Message sent by a client to request a state snapshot

Server

publisher #

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

subscriber #

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.

queryLastState #

Arguments

:: Binary a 
=> String

Address of the server's ROUTER socket

-> IO a 

Only request the most recent state from the server.

This function will query the ROUTER port for the latest state, and return it.