nats-client-0.1.0.0: Another Haskell client for NATS (https://nats.io)

Safe HaskellNone
LanguageHaskell2010

Network.Nats.Protocol

Description

 

Synopsis

Documentation

class (Monad m, MonadIO m) => Connection m where Source #

Connection context for abstracting away IO

Minimal complete definition

receiveRawMessage, sendRawMessage

Instances

Connection IO Source #

Default IO implementation using bytestrings

newtype Subject Source #

Name of a NATS subject. Must be a dot-separated alphanumeric string, with ">" and "." as wildcard characters. See http://nats.io/documentation/internals/nats-protocol/

Constructors

Subject ByteString 

Instances

data QueueGroup Source #

Type for representing Queue Groups, used to implement round-robin receivers

defaultConnectionOptions :: NatsConnectionOptions Source #

Default client connection options, for convenience.

defaultTimeout :: Int Source #

Default client timeout, in millisseconds

receiveMessage :: (MonadThrow m, Connection m) => Handle -> Int -> m Message Source #

Receive a Message from the server

receiveServerBanner :: Connection m => Handle -> m (Either String NatsServerInfo) Source #

Receive the initial server banner from an INFO message, or an error message if it cannot be parsed.

sendConnect :: Connection m => Handle -> NatsConnectionOptions -> m () Source #

Send a CONNECT message to the server

sendPong :: Connection m => Handle -> m () Source #

Send a PONG message to the server, typically in reply to a PING challenge.

sendPub :: Connection m => Handle -> Subject -> Int -> ByteString -> m () Source #

Send a publish request to the server

sendSub :: Connection m => Handle -> Subject -> SubscriptionId -> Maybe QueueGroup -> m () Source #

Send a Subscription request to a Subject, with a SubscriptionId and optionally a QueueGroup.

sendUnsub :: Connection m => Handle -> SubscriptionId -> Maybe Int -> m () Source #

Send an unsubscription request with a SubscriptionId and optionally a maximum number of messages that will still be listened to.

data Message Source #

Messages received from the NATS server

Constructors

Message ByteString

A published message, containing a payload

OKMsg

Acknowledgment from server after a client request

ErrorMsg ByteString

Error message from server after a client request

Banner ByteString

Server "banner" received via an INFO message

Ping

Server ping challenge

Instances

parseMessage :: MonadThrow m => ByteString -> m Message Source #

Parses a Message from a ByteString

parseServerBanner :: ByteString -> Either String NatsServerInfo Source #

Specialized parsed to return a NatsServerInfo