hats- Haskell client for the NATS messaging system

Copyright(c) 2016 Patrik Sandahl
MaintainerPatrik Sandahl <patrik.sandahl@gmail.com>
Safe HaskellNone



Base types for the library's API. JSON support is implemented with Data.Aeson.



type Topic = ByteString Source #

The type of a topic where to publish, or to subscribe on. Type alias for ByteString.

type Payload = ByteString Source #

The type of a message payload. Type alias for ByteString.

type Sid = Int64 Source #

The numeric id for a subscription. An id shall be unique within a NATS client. The value of the id will be generated automatically by the API. Type alias for Int64.

type QueueGroup = ByteString Source #

A Topic subscriber can be part of a queue group, an entity for load balancing in NATS. Type alias for ByteString.

data NatsException Source #

Exceptions generated from within this library.



An exception caused by errors during the NATS connection handshake. Will not popup on user level, only handled internally.


An exception thrown when all the configured connection attempts are consumed and the connection manager has been given up.


The NATS server currently connected to has said that there are authorization violations. Don't try to survive, just tell the user that there are such errors.

URIError !String

An exception caused by invalid URI strings given to the withNats function.

newtype MsgQueue Source #

A message queue, a queue of Msgs handled by a TQueue.


MsgQueue (TQueue Msg) 

data Msg Source #

A NATS message as received by the user. The message itself is opaque to the user, but the fields can be read by the API functions topic, replyTo, sid, payload, jsonPayload and jsonPayload'


Msg !Topic !(Maybe Topic) !Sid !Payload 


Eq Msg Source # 


(==) :: Msg -> Msg -> Bool #

(/=) :: Msg -> Msg -> Bool #

Show Msg Source # 


showsPrec :: Int -> Msg -> ShowS #

show :: Msg -> String #

showList :: [Msg] -> ShowS #

topic :: Msg -> Topic Source #

Read the complete topic on which a message was received.

replyTo :: Msg -> Maybe Topic Source #

Read the reply-to topic from a received message.

sid :: Msg -> Sid Source #

Read the subscription id for the subscription on which this message was received.

payload :: Msg -> Payload Source #

Read the raw payload from a received message.

jsonPayload :: FromJSON a => Msg -> Maybe a Source #

Decode a message's payload as JSON. Is using decode for the decoding.

jsonPayload' :: FromJSON a => Msg -> Maybe a Source #

Decode a message's payload as JSON. Is using decode' for the decoding.