StatifierOban.Timer.Key (StatifierOban v0.1.1)

Copy Markdown View Source

Derives the two scoped keys a durable-timer store needs, per ADR-0054 decision 3 as amended by ADR-0059, and docs/durable-timers.md ("Keying your store") in statifier-ex.

The dedup key is the compact {scope, ordinal} pair ADR-0059 decision 3 blesses; the cancellation key is {scope, send_id}, which ADR-0059 leaves untouched. Because send_id is row data rather than a dedup-key component here, a cancel matches stored rows through cancels?/3, against the row's stored effect.

scope is always an argument and never derived: Statifier's counters restart for every chart run, so send_1 (or ordinal 1) from one run addresses the same row as its twin from an unrelated run unless the store keeps them apart. It is ctx.session_id (spec 5.10's _sessionid) for a live session, or the host's own durable run id for a process-less host.

Summary

Types

error()

@type error() :: :invalid_scope | :missing_send_id | :missing_ordinal

scope()

@type scope() :: String.t()

Functions

cancellation_key(scope, arg2)

cancels?(cancellation_key, scope, send_delayed)

Whether a cancellation key addresses the stored effect under a scope.

Spec 6.3 cancels every delayed send under a sendid; the stored effect's send_id is row data, not a dedup-key component, so the match reads it off the row rather than off the key.

dedup_key(scope, send_delayed)

@spec dedup_key(scope(), Statifier.Effect.SendDelayed.t()) ::
  {:ok, StatifierOban.Timer.DedupKey.t()} | {:error, error()}