patterns-0.1.1: Common patterns in message-oriented applications

Safe HaskellNone




Publish side of 'Publish/Subscribe'



data Pub Source

Publisher data type

withPub :: Context -> String -> LinkType -> (Pub -> IO a) -> IO aSource

Create and link a publisher:

  • Context - The zeromq context
  • String - The service address
  • LinkType - How to link (bind or connect)
  • (Pub -> IO a) - The action, in whose scope the publisher lives

issue :: Pub -> [Service] -> Source -> IO ()Source

Publish data:

  • Pub - The publisher
  • [Service] - List of topics, to which these data should be published
  • Source - Create the stream to publish. The first message segment contains the subscription header, i.e. the comma-separated list of topics


withForwarder :: Context -> Service -> [Service] -> (String, LinkType) -> (String, LinkType) -> OnError_ -> Control a -> IO aSource

A simple forwarder, i.e. a device that connects to a publisher and provides an additional endpoint for more subscribers to connect to. A forwarder, hence, is a means to extend the capacity of a publisher.

  • Context - The zeromq context
  • Service - The name of the forwarder
  • (String, LinkType) - access point for subscribers; usually, you want to bind the address, such that subscribers connect to it.
  • (String, LinkType) - access point for the publisher; usually, you want to connect to the publisher.
  • OnError_ - Error handler
  • Control a - Control loop