Snodo.Extension.Registry (snodo v0.1.0)

Copy Markdown View Source

Immutable registry for explicitly installed extension modules.

Registration rejects collisions against the complete core catalog for an exact protocol revision, including unsupported and MRTR-only method names. Installation, advertisement, and peer negotiation are separate. Extension routes require negotiation; advertised compatible middleware can observe an unnegotiated request and enforce policy before core execution.

Summary

Functions

Wraps core dispatch in advertised, compatible extension middleware.

Adds application-owned options for installed extensions compatible with the context.

Shapes a protocol-neutral event through its negotiated owning extension.

Collects validated, collision-free subscription filter fields from advertised extensions.

Applies an advertised extension route's exact-versioned transport policy hook.

Types

continuation()

@type continuation() :: (Snodo.Context.t() -> dispatch_result())

dispatch_result()

@type dispatch_result() :: {:ok, Snodo.Result.t()} | {:error, Snodo.Error.t()}

entry()

@type entry() :: module() | {module(), extension_options()}

extension_options()

@type extension_options() :: keyword() | map()

t()

@type t() :: %Snodo.Extension.Registry{
  by_id: %{optional(String.t()) => module()},
  options_by_id: %{optional(String.t()) => extension_options()},
  ordered_ids: [String.t()],
  routes: %{optional({String.t(), String.t()}) => Snodo.Extension.Route.t()},
  versions_by_id: %{optional(String.t()) => MapSet.t(String.t())}
}

Functions

around_dispatch(registry, version, operation, params, context, next)

@spec around_dispatch(
  t(),
  String.t(),
  term(),
  map(),
  Snodo.Context.t(),
  continuation()
) :: dispatch_result()

Wraps core dispatch in advertised, compatible extension middleware.

put_options(registry, context)

@spec put_options(t(), Snodo.Context.t()) :: Snodo.Context.t()

Adds application-owned options for installed extensions compatible with the context.

shape_subscription_event(registry, event, subscription_id, context)

@spec shape_subscription_event(
  t(),
  Snodo.Subscription.Event.t(),
  Snodo.Envelope.id(),
  Snodo.Context.t()
) :: {:ok, map()} | :drop | {:error, Snodo.Error.t()}

Shapes a protocol-neutral event through its negotiated owning extension.

subscription_filters(registry, version, requested_filter, context)

@spec subscription_filters(t(), String.t(), map(), Snodo.Context.t()) ::
  {:ok, map(), %{optional(String.t()) => map()}} | {:error, Snodo.Error.t()}

Collects validated, collision-free subscription filter fields from advertised extensions.

transport_policy(registry, version, envelope, server_capabilities, base_policy)

@spec transport_policy(
  t(),
  String.t(),
  Snodo.Envelope.t(),
  map(),
  Snodo.Transport.Policy.t()
) ::
  {:ok, Snodo.Transport.Policy.t()} | {:error, Snodo.Error.t()}

Applies an advertised extension route's exact-versioned transport policy hook.