SwimEx.Transport behaviour (SwimEx v0.1.0)

View Source

Behaviour for SWIM transport implementations.

Implementations must deliver received packets to the registered receiver as {:swim_packet, from :: {String.t(), port}, binary}.

Summary

Callbacks

Close the transport.

Send a binary payload to the given node.

Register the process that will receive incoming packets.

Start the transport, binding to the given port.

Functions

Strips the cookie from a 3-element identity tuple, returning a 2-element transport address.

Types

node_id()

@type node_id() :: {String.t(), :inet.port_number()}

server()

@type server() :: GenServer.server()

Callbacks

close(server)

@callback close(server()) :: :ok

Close the transport.

send(server, node_id, binary)

@callback send(server(), node_id(), binary()) :: :ok | {:error, term()}

Send a binary payload to the given node.

set_receiver(server, pid)

@callback set_receiver(server(), pid()) :: :ok

Register the process that will receive incoming packets.

start_link(keyword)

@callback start_link(keyword()) :: GenServer.on_start()

Start the transport, binding to the given port.

Functions

strip_cookie(arg)

@spec strip_cookie({String.t(), :inet.port_number(), String.t()} | node_id()) ::
  node_id()

Strips the cookie from a 3-element identity tuple, returning a 2-element transport address.