patterns-0.1.1: Common patterns in message-oriented applications

Portabilitynon-portable
Stabilityexperimental
Safe HaskellNone

Network.Mom.Patterns.Broker.Client

Description

Majordomo Client

Synopsis

Documentation

data Client Source

Client data type

withClient :: Context -> Service -> String -> LinkType -> (Client -> IO a) -> IO aSource

Create a client and start the action, in whose scope the client lives;

checkService :: Client -> Timeout -> IO (Maybe Bool)Source

Service discovery: The function checks whether the client's service is provided by the broker.

Return values:

  • Nothing: The broker timed out
  • Just False: The service is not available
  • Just True: The service is available

request :: Client -> Timeout -> Source -> SinkR (Maybe a) -> IO (Maybe a)Source

Request a service:

  • Client - The client, through which the service is requested
  • Timeout - Timeout in microseconds, -1 to wait eternally. With timeout = 0, the function returns immediately with Nothing. When the timeout expires, request is abandoned. In this case, the result of the request is Nothing.
  • Source - The source of the request stream; the format of the request will probably comply with some communication protocol, as, for instance, in the majordomo pattern.
  • SinkR - The sink receiving the reply. The result of the sink is returned as the request's overall result. Note that the sink may perform different actions on the segments of the resulting stream, e.g. storing data in a database, and return the number of records received.

checkResult :: Client -> Timeout -> SinkR (Maybe a) -> IO (Maybe a)Source

Check for a of a previously requested result; use case: request with timout 0, do some work and check for a result later. Do not use this function without having requested the service previously. The parameters equal those of request, but do not include a Source.