MOQX.Protocol behaviour (moqx v0.10.0)

Copy Markdown View Source

Contract between the protocol-neutral connection runtime and one concrete MOQT-family protocol implementation.

Implementations own their wire messages, codecs, lifecycle, capabilities, commands, events, and error semantics. The runtime owns the MOQX.Transport context and applies the transport actions returned in MOQX.Protocol.Transition values.

An explicit {:attempt_actions, key, actions} batch reports its first failure or success immediately through handle_transport/2 as {:action_result, key, result}. The runtime reports mechanics only; the protocol owns the meaning and recovery transition. Ordinary actions remain fail-fast, with application events emitted only after their transition actions succeed.

Summary

Functions

Returns whether a module exports the complete protocol implementation contract.

Types

action_result()

@type action_result() :: :ok | {:error, term()}

id()

@type id() :: :cloudflare_draft_14 | :draft_16

runtime_event()

@type runtime_event() ::
  {:runtime_timeout, term()} | {:action_result, term(), action_result()}

state()

@type state() :: term()

Callbacks

capabilities(state)

@callback capabilities(state()) :: MOQX.Protocol.Capabilities.t()

handle_operation(state, t)

@callback handle_operation(state(), MOQX.Operation.t()) ::
  MOQX.Protocol.Transition.result()

handle_transport(state, arg2)

@callback handle_transport(state(), MOQX.Transport.event() | runtime_event()) ::
  MOQX.Protocol.Transition.result()

id()

@callback id() :: id() | atom()

init(endpoint, options)

@callback init(endpoint :: URI.t(), options :: keyword()) ::
  {:ok, state()} | {:error, term()}

transport_spec(endpoint, options)

@callback transport_spec(endpoint :: URI.t(), options :: keyword()) ::
  {:ok, MOQX.Protocol.TransportSpec.t()} | {:error, term()}

Functions

implementation?(module)

@spec implementation?(module()) :: boolean()

Returns whether a module exports the complete protocol implementation contract.