Spectre.Operation.Delivery.Policy (Spectre v0.3.0)

Copy Markdown View Source

Deterministic consent, deduplication, rate and quiet-hours policy.

Summary

Functions

Builds a validated policy from a struct, map, keyword list or nil.

Validates the policy's flags, limits, quiet hours, offset, mode and portability.

Types

t()

@type t() :: %Spectre.Operation.Delivery.Policy{
  channels: term(),
  consent_required: term(),
  dedupe_ttl_ms: term(),
  event_types: term(),
  max_deliveries: term(),
  metadata: term(),
  mode: term(),
  quiet_hours: term(),
  utc_offset_minutes: term(),
  window_ms: term()
}

Functions

new(policy)

@spec new(t() | map() | keyword() | nil) :: t()

Builds a validated policy from a struct, map, keyword list or nil.

nil yields the default policy. Raises ArgumentError when the resulting policy is invalid.

validate(policy)

@spec validate(t()) :: :ok | {:error, term()}

Validates the policy's flags, limits, quiet hours, offset, mode and portability.

Returns :ok, or {:error, reason} naming the first invalid field.