nats_msg (enats_msg v1.0.2)
View SourceSummary
Functions
Encodes a CONNECT message sent by the client to provide connection details and security information. The argument is the JSON connect options payload.
Decodes a binary or iolist containing NATS protocol messages. Stops after the first complete message is decoded. Returns the decoded message term and any remaining binary data.
Decodes a binary or iolist containing NATS protocol messages using a callback function to handle decoded events.
The callback function is called with (Event, State)
and should return {continue, NewState}
or {stop, FinalState}
.
Returns the final state returned by the callback and any remaining binary data.
Decodes all complete NATS protocol messages found in the input binary. Returns a list of decoded messages and any remaining binary data.
Encodes an Erlang term representing a NATS protocol message into an iolist suitable for sending over the wire.
Encodes an -ERR message indicating a protocol error.
Encodes an HMSG message with no reply-to, empty header, and empty payload.
Encodes an HMSG message with no reply-to.
Encodes an HMSG message.
Encodes an HPUB message to publish data with headers to a subject with empty header and payload.
Encodes an HPUB message to publish data with headers to a subject.
Encodes an HPUB message to publish data with headers to a subject, optionally including a reply subject.
Encodes an INFO message sent by the server to provide connection information. The argument is the JSON info payload.
Initializes the nats_msg module.
Encodes a MSG message with no reply-to and empty payload.
Encodes a MSG message.
Encodes a +OK acknowledgement message.
Encodes a PING keep-alive message.
Encodes a PONG keep-alive response.
Encodes a PUB message to publish data to a subject with an empty payload.
Encodes a PUB message to publish data to a subject, optionally including a reply subject.
Encodes a SUB message to subscribe to a subject.
Encodes a SUB message to subscribe to a subject, optionally joining a queue group.
Encodes an UNSUB message to unsubscribe from a subject.
Encodes an UNSUB message to unsubscribe from a subject after a certain number of messages.
Types
-type encode_param() :: ping | pong | ok | error | {info, iodata()} | {connect, iodata()} | error_param() | pub_param() | hpub_param() | sub_param() | unsub_param() | msg_param() | hmsg_param().
-type error_atom() ::
unknown_operation | auth_violation | auth_timeout | parser_error | stale_connection |
slow_consumer | max_payload | invalid_subject.
-type error_param() :: {error, error_atom()}.
Functions
Encodes a CONNECT message sent by the client to provide connection details and security information. The argument is the JSON connect options payload.
Decodes a binary or iolist containing NATS protocol messages. Stops after the first complete message is decoded. Returns the decoded message term and any remaining binary data.
Decodes a binary or iolist containing NATS protocol messages using a callback function to handle decoded events.
The callback function is called with (Event, State)
and should return {continue, NewState}
or {stop, FinalState}
.
Returns the final state returned by the callback and any remaining binary data.
Decodes all complete NATS protocol messages found in the input binary. Returns a list of decoded messages and any remaining binary data.
-spec encode(Param :: encode_param()) -> iolist().
Encodes an Erlang term representing a NATS protocol message into an iolist suitable for sending over the wire.
-spec err(Msg :: error_atom()) -> iolist().
Encodes an -ERR message indicating a protocol error.
Encodes an HMSG message with no reply-to, empty header, and empty payload.
-spec hmsg(Subject :: iodata(), Sid :: iodata(), Header :: iodata(), Payload :: iodata()) -> iolist().
Encodes an HMSG message with no reply-to.
-spec hmsg(Subject :: iodata(), Sid :: iodata(), ReplyTo :: iodata() | undefined, Header :: iodata(), Payload :: iodata()) -> iolist().
Encodes an HMSG message.
Encodes an HPUB message to publish data with headers to a subject with empty header and payload.
Encodes an HPUB message to publish data with headers to a subject.
-spec hpub(Subject :: iodata(), ReplyTo :: iodata() | undefined, Header :: iodata(), Payload :: iodata()) -> iolist().
Encodes an HPUB message to publish data with headers to a subject, optionally including a reply subject.
Encodes an INFO message sent by the server to provide connection information. The argument is the JSON info payload.
-spec init() -> ok.
Initializes the nats_msg module.
Encodes a MSG message with no reply-to and empty payload.
-spec msg(Subject :: iodata(), Sid :: iodata(), ReplyTo :: iodata() | undefined, Payload :: iodata()) -> iolist().
Encodes a MSG message.
-spec ok() -> iolist().
Encodes a +OK acknowledgement message.
-spec ping() -> iolist().
Encodes a PING keep-alive message.
-spec pong() -> iolist().
Encodes a PONG keep-alive response.
Encodes a PUB message to publish data to a subject with an empty payload.
Encodes a PUB message to publish data to a subject, optionally including a reply subject.
Encodes a SUB message to subscribe to a subject.
Encodes a SUB message to subscribe to a subject, optionally joining a queue group.
Encodes an UNSUB message to unsubscribe from a subject.
Encodes an UNSUB message to unsubscribe from a subject after a certain number of messages.