Wardrik.Channel.Installations behaviour (wardrik_protocol v0.1.0-rc.1)

Copy Markdown

A behaviour for storing the workspaces a channel is added to, each with its token.

Pass an implementation to a channel as installations: {module, config}. The host then keeps workspaces with its own records. A channel given token: instead serves only the workspace that token reaches.

Tokens are secrets. Store them as you store your others.

Summary

Callbacks

Deletes the channel's installation in workspace. Returns :ok if there is none.

Fetches the channel's installation in workspace, as the chat app names it.

Returns the channel's installations owned by owner, as acme or acme/@jon.

Stores installation, replacing any with the same channel and workspace.

Callbacks

delete(config, channel, workspace)

@callback delete(config :: term(), channel :: String.t(), workspace :: String.t()) :: :ok

Deletes the channel's installation in workspace. Returns :ok if there is none.

fetch(config, channel, workspace)

@callback fetch(config :: term(), channel :: String.t(), workspace :: String.t()) ::
  {:ok, Wardrik.Channel.Installation.t()} | :error

Fetches the channel's installation in workspace, as the chat app names it.

owned(config, channel, owner)

@callback owned(config :: term(), channel :: String.t(), owner :: String.t()) :: [
  Wardrik.Channel.Installation.t()
]

Returns the channel's installations owned by owner, as acme or acme/@jon.

put(config, t)

@callback put(config :: term(), Wardrik.Channel.Installation.t()) ::
  :ok | {:error, String.t()}

Stores installation, replacing any with the same channel and workspace.