Snodo.Protocol behaviour (snodo v0.1.0)

Copy Markdown View Source

Behaviour for version-specific lifecycle, admission, routing, and wire shaping.

Dialects are supplied explicitly to a runtime. Merely loading a dialect module never enables it.

Summary

Functions

Returns the exact profiles bundled in-tree, independent of a runtime allowlist.

Returns the bundled profile versions in preference order.

Returns the untouched _meta map or an empty map.

Callbacks

build_context(t, t)

@callback build_context(Snodo.Envelope.t(), Snodo.Server.Runtime.t()) ::
  {:ok, Snodo.Context.t()} | {:error, Snodo.Error.t()}

decode_request(map, t)

@callback decode_request(map(), Snodo.Transport.Context.t()) ::
  {:ok, Snodo.Envelope.t()} | {:error, Snodo.Error.t()}

detect(t)

@callback detect(Snodo.Envelope.t()) :: :exact | :fallback | false

era()

@callback era() :: :session | :stateless

profile()

@callback profile() :: Snodo.Protocol.Profile.t()

request_metadata(map)

@callback request_metadata(map()) :: map()

resolve_operation(t)

@callback resolve_operation(Snodo.Envelope.t()) ::
  {:ok, term()} | :not_handled | {:error, Snodo.Error.t()}

server_discovery(t)

@callback server_discovery(Snodo.Server.Runtime.t()) :: map() | :unsupported

shape_error(t, arg2)

@callback shape_error(Snodo.Error.t(), Snodo.Context.t() | nil) :: map()

shape_progress(arg1, map, t)

(optional)
@callback shape_progress(String.t() | integer(), map(), Snodo.Context.t()) :: map()

Optional shaping of an active request's progress notification, independent of subscriptions.

shape_result(term, t, t)

@callback shape_result(term(), Snodo.Result.t(), Snodo.Context.t()) :: map()

shape_subscription_ack(map, id, t)

(optional)
@callback shape_subscription_ack(map(), Snodo.Envelope.id(), Snodo.Context.t()) :: map()

shape_subscription_event(t, id, t)

(optional)
@callback shape_subscription_event(
  Snodo.Subscription.Event.t(),
  Snodo.Envelope.id(),
  Snodo.Context.t()
) ::
  map()

shape_subscription_result(id, t)

(optional)
@callback shape_subscription_result(Snodo.Envelope.id(), Snodo.Context.t()) :: map()

transport_policy(arg1)

@callback transport_policy(Snodo.Envelope.t() | nil) :: Snodo.Transport.Policy.t()

validate_operation(term, map, t)

@callback validate_operation(term(), map(), Snodo.Context.t()) ::
  :ok | {:error, Snodo.Error.t()}

validate_result(term, t, t)

(optional)
@callback validate_result(term(), Snodo.Result.t(), Snodo.Context.t()) ::
  :ok | {:error, Snodo.Error.t()}

Optional post-handler admission for dialect-specific result variants and capabilities.

version()

@callback version() :: String.t()

Functions

builtin_profiles()

@spec builtin_profiles() :: [Snodo.Protocol.Profile.t()]

Returns the exact profiles bundled in-tree, independent of a runtime allowlist.

builtin_versions()

@spec builtin_versions() :: [String.t()]

Returns the bundled profile versions in preference order.

request_meta(envelope)

@spec request_meta(Snodo.Envelope.t()) :: map()

Returns the untouched _meta map or an empty map.