hats-0.1.0.1: Haskell client for the NATS messaging system

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

Network.Nats.Message.Message

Description

Message definitions for the NATS protocol.

Synopsis

Documentation

data Message Source #

The kind of messages that can be exchanged between the NATS server and a NATS client. Some of the documentation strings are taken from: https://nats.io/documentation/internals/nats-protocol/

Constructors

INFO

As soon as the server accepts a connection from the client, it will send information about itself and the configuration and security requirements that are necessary for the client to successfully authenticate with the server and exchange messages.

Fields

CONNECT

The CONNECT message is the reply to the Info message. Once the client has established a TCP/IP socket connection with the NATS server, and an Info message has been received from the server, the client may sent a Connect message to the NATS server to provide more information about the current connection as well as security information.

Fields

MSG !Topic !Sid !(Maybe Topic) !Payload

The MSG message carries payload from the server to the client. subject: Subject name this message was received on. sid: The unique alphanumeric subscription ID of the subject. reply-to: The inbox subject on which the publisher is listening for responses. #bytes: Implicit by the length of the payload. payload: The message payload data.

PUB !Topic !(Maybe Topic) !Payload

The PUB message publishes the message payload to the given subject name. If a reply subject is supplied, it will be delivered to eligible subscribers along with the supplied payload. Payload can be zero size. subject: The destination subject to publish to. reply-to: The reply inbox subject that subscribers can use to send a response back to the publisher/requestor. #bytes: Implicit by the length of payload. payload: The message payload data.

SUB !Topic !(Maybe QueueGroup) !Sid

The SUB message initiates a subscription to a subject, optionally joining a distributed queue group. subject: The subject name to subscribe to. (Optional) queue group: If specified, the subscriper will join this queue group. sid: A unique alphanumeric SubscriptionId.

UNSUB !Sid !(Maybe Int)

The UNSUB message unsubscribes the connection from the specified subject, or auto-unsubscribes after the specified number of messages has been received.

PING

The PING and PONG messages are the keep-alive mechanism between the client and the server. The server will continously send Ping messages to the client. If the client does not reply within time the connection is terminated by the server.

PONG 
OK

When the verbose (clientVerbose) option is set to true, the server acknowledges each well-formed prototol message from the client with a +OK message.

ERR !ProtocolError

The -ERR message is used by the server indicate a protocol, authorization, or other runtime connection error to the client. Most of those errors result in the server closing the connection. InvalidSubject is the exception.

Instances

Eq Message Source # 

Methods

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

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

Show Message Source # 
Generic Message Source # 

Associated Types

type Rep Message :: * -> * #

Methods

from :: Message -> Rep Message x #

to :: Rep Message x -> Message #

NFData Message Source # 

Methods

rnf :: Message -> () #

type Rep Message Source # 
type Rep Message = D1 (MetaData "Message" "Network.Nats.Message.Message" "hats-0.1.0.1-2AWM2wK1QrH5pmEtqZR40G" False) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "INFO" PrefixI True) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "serverId") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe ByteString))) (S1 (MetaSel (Just Symbol "serverVersion") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe ByteString)))) ((:*:) (S1 (MetaSel (Just Symbol "goVersion") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe ByteString))) ((:*:) (S1 (MetaSel (Just Symbol "serverHost") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe ByteString))) (S1 (MetaSel (Just Symbol "serverPort") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Int)))))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "serverAuthRequired") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Bool))) (S1 (MetaSel (Just Symbol "serverSslRequired") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Bool)))) ((:*:) (S1 (MetaSel (Just Symbol "serverTlsRequired") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Bool))) ((:*:) (S1 (MetaSel (Just Symbol "serverTlsVerify") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Bool))) (S1 (MetaSel (Just Symbol "maxPayload") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Int)))))))) (C1 (MetaCons "CONNECT" PrefixI True) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "clientVerbose") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Bool))) (S1 (MetaSel (Just Symbol "clientPedantic") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Bool)))) ((:*:) (S1 (MetaSel (Just Symbol "clientSslRequired") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Bool))) (S1 (MetaSel (Just Symbol "clientAuthToken") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe ByteString))))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "clientUser") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe ByteString))) (S1 (MetaSel (Just Symbol "clientPass") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe ByteString)))) ((:*:) (S1 (MetaSel (Just Symbol "clientName") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe ByteString))) ((:*:) (S1 (MetaSel (Just Symbol "clientLang") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe ByteString))) (S1 (MetaSel (Just Symbol "clientVersion") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe ByteString))))))))) ((:+:) (C1 (MetaCons "MSG" PrefixI False) ((:*:) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Topic)) (S1 (MetaSel (Nothing Symbol) SourceUnpack SourceStrict DecidedStrict) (Rec0 Sid))) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Topic))) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Payload))))) ((:+:) (C1 (MetaCons "PUB" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Topic)) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Topic))) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Payload))))) (C1 (MetaCons "SUB" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Topic)) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe QueueGroup))) (S1 (MetaSel (Nothing Symbol) SourceUnpack SourceStrict DecidedStrict) (Rec0 Sid)))))))) ((:+:) ((:+:) (C1 (MetaCons "UNSUB" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) SourceUnpack SourceStrict DecidedStrict) (Rec0 Sid)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 (Maybe Int))))) (C1 (MetaCons "PING" PrefixI False) U1)) ((:+:) (C1 (MetaCons "PONG" PrefixI False) U1) ((:+:) (C1 (MetaCons "OK" PrefixI False) U1) (C1 (MetaCons "ERR" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 ProtocolError)))))))

data ProtocolError Source #

Protocol error enumeration.

Instances

Bounded ProtocolError Source # 
Enum ProtocolError Source # 
Eq ProtocolError Source # 
Show ProtocolError Source # 
Generic ProtocolError Source # 

Associated Types

type Rep ProtocolError :: * -> * #

NFData ProtocolError Source # 

Methods

rnf :: ProtocolError -> () #

type Rep ProtocolError Source # 
type Rep ProtocolError = D1 (MetaData "ProtocolError" "Network.Nats.Message.Message" "hats-0.1.0.1-2AWM2wK1QrH5pmEtqZR40G" False) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "UnknownProtocolOperation" PrefixI False) U1) (C1 (MetaCons "AuthorizationViolation" PrefixI False) U1)) ((:+:) (C1 (MetaCons "AuthorizationTimeout" PrefixI False) U1) (C1 (MetaCons "ParserError" PrefixI False) U1))) ((:+:) ((:+:) (C1 (MetaCons "StaleConnection" PrefixI False) U1) (C1 (MetaCons "SlowConsumer" PrefixI False) U1)) ((:+:) (C1 (MetaCons "MaximumPayloadExceeded" PrefixI False) U1) (C1 (MetaCons "InvalidSubject" PrefixI False) U1))))