Provides types and utilities for the NATS protocol
Typed operations of the NATS protocol
Here is the protocol documentation:
CONNECT Client Sent to server to specify connection information
PUB Client Publish a message to a subject, with optional reply subject
SUB Client Subscribe to a subject (or subject wildcard)
UNSUB Client Unsubscribe (or auto-unsubscribe) from subject
MSG Server Delivers a message payload to a subscriber
PING Both PING keep-alive message
PONG Both PONG keep-alive response
+OK Server Acknowledges well-formed protocol message in verbose mode
-ERR Server Indicates a protocol error. Will cause client disconnect.
{ subject : String
, replyTo : String
, size : Basics.Int
, data : datatype
}
A NATS message
{ server_id : String
, version : String
, go : String
, host : String
, port_ : Basics.Int
, auth_required : Basics.Bool
, max_payload : Basics.Int
}
Information sent by the server immediately after opening the connection
{ verbose : Basics.Bool
, pedantic : Basics.Bool
, auth_token : Maybe String
, user : Maybe String
, pass : Maybe String
, name : Maybe String
, lang : String
, version : String
, protocol : Basics.Int
}
Options for the CONNECT operation
parseString : ParseState String -> String -> ParseResult String
Parse an operation (generally received from the server) from a string
Any message contained will be of type 'String'
parseBytes : ParseState Bytes -> Bytes -> ParseResult Bytes
Parse an operation from binary data.
Any message contained will be of type 'Bytes'
toBytes : Operation Bytes -> Bytes
serialize to Bytes
toString : Operation String -> String
serialize an Operation (generally for sending to the server)
if the operation contains data as bytes, the result string will be base64 encoded
Result String ( List (Operation datatype)
, ParseState datatype
}
The result of parsing an operation
A temporary state when a parsing an operation is incomplete
initialParseState : ParseState datatype
Returns a initial ParseState