EKV.Transport behaviour (ekv v0.4.2)

Copy Markdown

Minimal adapter boundary for EKV data-plane traffic.

EKV uses this boundary for member shard sends and routed client RPC. The default adapter keeps Erlang distribution behavior; callers may provide a volatile ordered lane without EKV owning that lane's supervision.

Public transport config is nil or {Module, opts}. EKV validates Module implements this behaviour and passes opts directly to Module.init/1; adapter option keys are adapter-owned and not interpreted by EKV.

init/1 prepares a lightweight adapter handle from static configuration. EKV calls it once per replica shard process for member traffic and may call it on the routed-client-RPC hot path. Adapter implementations must not start per-call transport workers from init/1; long-lived transport processes should be supervised by the application that owns the transport.

Summary

Types

config()

@type config() :: %{module: module(), opts: keyword()}

external_config()

@type external_config() :: nil | {module(), keyword()}

handle()

@type handle() :: {module(), term()}

target()

@type target() :: pid() | atom() | {atom(), node()}

Callbacks

init(keyword)

@callback init(keyword()) :: {:ok, term()} | {:error, term()}

rpc(term, node, module, atom, list, keyword)

@callback rpc(term(), node(), module(), atom(), [term()], keyword()) ::
  {:ok, term()}
  | {:raise, term()}
  | {:throw, term()}
  | {:exit, term()}
  | {:error, term()}

send(term, target, term, keyword)

@callback send(term(), target(), term(), keyword()) :: :ok | {:error, term()}