ProtoRune. Firehose. Transport behaviour
(proto_rune v0.3.0)
Copy Markdown
Behaviour for the WebSocket transport used by ProtoRune.Firehose.
A transport owns the underlying connection and translates the BEAM
messages it receives into firehose frames. The default implementation is
ProtoRune.Firehose.Transport.Gun; a different implementation can be
injected through the :transport and :transport_opts options of
ProtoRune.Firehose.start_link/1, which is how the connection lifecycle
is exercised in tests.
Summary
Types
Opaque transport connection state.
A decoded WebSocket frame: a binary payload or a close signal.
Callbacks
Closes the connection.
Opens a WebSocket connection to the given ws(s):// URL.
Processes a message received by the connection owner.
Types
Callbacks
@callback close(conn()) :: :ok
Closes the connection.
Opens a WebSocket connection to the given ws(s):// URL.
The calling process becomes the connection owner and receives the
socket-related messages that stream/2 understands.
@callback stream(conn(), message :: term()) :: {:ok, conn(), [frame()]} | :unknown | {:error, conn(), term()}
Processes a message received by the connection owner.
Returns :unknown when the message does not belong to the transport,
{:ok, conn, frames} with the decoded frames, or {:error, conn, reason}
when the connection failed.