Behaviour and dispatch helpers for pluggable session-channel persistence.
Updates are atomic read-modify-write operations. A backend must invoke the callback and persist its successful result without another update to the same channel interleaving between those steps.
MPP.Session.ETSStore is the application-started single-node default.
Summary
Callbacks
Delete channel state.
Look up a channel by ID.
Insert or replace channel state.
Atomically update channel state.
Functions
Return the application-started ETS store.
Delete a channel through a store reference.
Look up a channel through a store reference.
Insert or replace a channel through a store reference.
Atomically update a channel through a store reference.
Types
@type update_fun() :: (MPP.Session.Channel.t() | :not_found -> {:ok, MPP.Session.Channel.t()} | {:error, term()})
Callbacks
Delete channel state.
@callback get(channel_id :: String.t()) :: {:ok, MPP.Session.Channel.t()} | :not_found | {:error, term()}
Look up a channel by ID.
@callback put(channel :: MPP.Session.Channel.t()) :: :ok | {:error, term()}
Insert or replace channel state.
@callback update(channel_id :: String.t(), fun :: update_fun()) :: {:ok, MPP.Session.Channel.t()} | {:error, term()}
Atomically update channel state.
Functions
@spec default_store() :: module()
Return the application-started ETS store.
Delete a channel through a store reference.
@spec get(store_ref(), String.t()) :: {:ok, MPP.Session.Channel.t()} | :not_found | {:error, term()}
Look up a channel through a store reference.
@spec put(store_ref(), MPP.Session.Channel.t()) :: :ok | {:error, term()}
Insert or replace a channel through a store reference.
@spec update(store_ref(), String.t(), update_fun()) :: {:ok, MPP.Session.Channel.t()} | {:error, term()}
Atomically update a channel through a store reference.