patterns-0.1.1: Common patterns in message-oriented applications

Safe HaskellNone



Subscriber side of 'Publish Subscribe'



data Sub Source

Subscription data type

withSub :: Context -> String -> LinkType -> (Sub -> IO a) -> IO aSource

Create a subscription and start the action, in which it lives

  • Context - The zeromq context
  • String - The address
  • LinkType - The link type, usually Connect
  • (Sub -> IO a) - The action, in which the subscription lives

subscribe :: Sub -> [Service] -> IO ()Source

Subscribe to a list of topics; Note that a subscriber has to subscribe to at least one topic to receive any data.

  • Sub - The subscriber
  • [Service] - The list of topics to subscribe to

checkSub :: Sub -> Timeout -> SinkR (Maybe a) -> IO (Maybe a)Source

Check for new data:

  • Sub - The subscriber
  • Timeout - When timeout expires, the function returns Nothing. Timeout may be -1 - listen eternally, 0 - return immediately, > 0 - timeout in microseconds
  • SinkR - Sink the result stream. Note that the subscription header, i.e. a message segment containing a comma-separated list of the topics, to which the data belong, is dropped.