Chimeway.Digests (chimeway v1.0.0)

Copy Markdown View Source

Public digest-rule persistence API for durable rule lookup and storage.

Digest flush execution closes automatically only when the configured dispatcher is Chimeway.Dispatch.Oban, because bucket accumulation can then schedule Chimeway.Dispatch.DigestFlushWorker from persisted window_ends_at state.

Hosts using any other dispatcher still retain the durable public emit_bucket/2 seam and are expected to drive flush execution explicitly. Chimeway does not imply built-in automatic digest scheduling outside the Oban path.

Summary

Functions

Emits a due digest bucket and returns the canonical emitted delivery identity.

Finds the first digest rule matching channel and rule selectors.

Fetches a digest rule by ID.

Lists digest rules, optionally filtered by exact-match fields.

Creates or updates a digest rule by stable rule_key and rule_version.

Types

rule_lookup()

@type rule_lookup() :: %{
  :channel => String.t(),
  optional(:notification_key) => String.t() | nil,
  optional(:category) => String.t() | nil,
  optional(:digest_key) => String.t() | nil
}

Functions

emit_bucket(bucket_or_id, opts \\ [])

@spec emit_bucket(
  binary() | map(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Emits a due digest bucket and returns the canonical emitted delivery identity.

This remains the explicit host-managed flush seam when Chimeway.Dispatch.Oban is not the configured dispatcher.

find_matching_rule(attrs)

@spec find_matching_rule(rule_lookup()) :: Chimeway.Digests.DigestRule.t() | nil

Finds the first digest rule matching channel and rule selectors.

get_rule!(id)

@spec get_rule!(binary()) :: Chimeway.Digests.DigestRule.t()

Fetches a digest rule by ID.

list_rules(opts \\ [])

@spec list_rules(keyword()) :: [Chimeway.Digests.DigestRule.t()]

Lists digest rules, optionally filtered by exact-match fields.

upsert_rule(attrs)

@spec upsert_rule(map()) ::
  {:ok, Chimeway.Digests.DigestRule.t()} | {:error, Ecto.Changeset.t()}

Creates or updates a digest rule by stable rule_key and rule_version.