SwimEx. Codec
(SwimEx v0.1.0)
View Source
Codec for SWIM protocol messages.
Handles serialization and deserialization of messages and gossip events. Uses Erlang External Term Format for simplicity.
Summary
Functions
Decodes a binary payload into a message.
Encodes a message into a binary payload.
Returns the maximum transmission unit (MTU) for SWIM packets.
Types
@type event() :: {:alive, node_id(), incarnation()} | {:suspect, node_id(), incarnation()} | {:dead, node_id(), incarnation()}
@type incarnation() :: non_neg_integer()
@type message() :: {:ping, node_id(), seq :: non_neg_integer(), [event()]} | {:ack, node_id(), seq :: non_neg_integer(), [event()]} | {:ping_req, node_id(), seq :: non_neg_integer(), target :: node_id(), [event()]} | {:fwd_ack, node_id(), seq :: non_neg_integer(), source :: node_id(), [event()]}
@type node_id() :: {String.t(), :inet.port_number(), String.t()}
Functions
Decodes a binary payload into a message.
Returns {:ok, message} or {:error, :invalid}.
Encodes a message into a binary payload.
Returns {:error, :too_large} if the resulting binary exceeds the MTU.
@spec mtu() :: non_neg_integer()
Returns the maximum transmission unit (MTU) for SWIM packets.