Amarula.RetryCache.ETS (amarula v0.2.4)

View Source

In-memory Amarula.RetryCache adapter — the default.

One :public, named ETS table per connection profile, holding {msg_id, entry}. Bounded to @max_entries; on overflow the oldest entries (by entry.ts) are evicted. State is lost on restart, which is acceptable: a retry receipt arrives within seconds of the original send.

Ownership

The table is created by ensure_local/2, called from Connection.init, so it is owned by the Connection process and named by profile. Because the table dies with its owner, a Connection crash/restart recreates it empty — so a poisoned entry can never outlive the restart it triggers (no crash-loop on a bad cached value).

It must be :public, not :protected: it is written from two processes — Connection itself (on a retry receipt) and each per-recipient ConversationSender (the Amarula.RetryCache.Step in the send pipe records the sent message there) — while ownership (and thus the restart-clearing lifetime above) stays with Connection.

Options

  • :max_entries — cap before eviction (default 200).

Summary

Functions

Create the profile's table, owned by the calling process (Connection). Called from Connection.init before any reader, so we never create lazily on first use — no create race, no rescue. Idempotent.

Functions

ensure_local(state, profile)

@spec ensure_local(map(), atom() | String.t()) :: :ok

Create the profile's table, owned by the calling process (Connection). Called from Connection.init before any reader, so we never create lazily on first use — no create race, no rescue. Idempotent.