Amarula.Conn (amarula v0.1.0)
View SourceA connection handle: everything Amarula knows about one connection, built once from its config at connect time and threaded through the protocol layer.
Fields:
:profile— the connection's identity, e.g.:primary. Required; it scopes storage and distinguishes connections.:storage— the resolvedAmarula.Storage.Scope(adapter + state). Passed, with:profile, to every storage operation.:retry_cache— the resolvedAmarula.RetryCache.Scope.:send_steps/:recv_steps— the plugin pipelines (lists of step funs). A step isfn ctx -> {:cont, ctx} | {:halt, reason};attach/2on a plugin appends to these (Req-style). The send pipeline runs before encrypt; the receive pipeline after decrypt, before the consumer sees the message.:config— the original config map (protocol settings: version, browser, websocket url, …).
Storage plugins receive only profile + the scope's adapter state — never this
struct — so a backend can't reach the socket pid or creds.
Summary
Functions
Append a step to the receive pipeline (runs after decrypt).
Append a step to the send pipeline (runs before encrypt).
Build a Conn from a connection config map.
Types
A pipeline step: transforms the ctx or halts the pipeline.
@type t() :: %Amarula.Conn{ config: map(), profile: Amarula.Storage.profile(), recv_steps: [step()], retry_cache: Amarula.RetryCache.Scope.t() | nil, send_steps: [step()], storage: Amarula.Storage.Scope.t() }
Functions
Append a step to the receive pipeline (runs after decrypt).
Append a step to the send pipeline (runs before encrypt).
Build a Conn from a connection config map.
Requires :profile (the connection name). Storage comes from :storage
(a {adapter, opts} spec or a prebuilt Scope); if omitted it defaults to
Amarula.Storage.default_adapter/0 (the File adapter unless configured
otherwise) rooted at AMARULA_DATA_DIR (or ./amarula_data). The adapter
scopes by :profile.
The returned Conn carries the default plugin pipelines (e.g. the retry-cache
send step). Attach more with a plugin's attach/2, Req-style:
Amarula.new(config) |> MyPlugin.attach() |> Amarula.connect()