Sovite.Queue.Entry (sovite v0.6.0)

Copy Markdown View Source

The delivery state of a queued message: its envelope, plus the Sovite.Queue.Records appended so far, replayed in order.

Each recipient is :pending (never tried), :deferred, :delivered, or :failed. Final states never change, so a record replayed after a crash cannot bring a delivered recipient back.

notified tells whether the sender was told about a recipient's failure or (when it asked with NOTIFY=SUCCESS) its delivery, or about an alias of expanded.

Summary

Types

The state of one recipient.

t()

Functions

Applies one record. Records for unknown recipients are ignored.

Returns true when every recipient is delivered or failed.

Builds the state from an envelope and its records.

Whether a notification of kind is due for address by its NOTIFY parameter (RFC 3461 §4.1). Without one, failures and delays are reported, and successes are not. :relay is anything but NEVER.

Recipients still to be delivered (pending or deferred), in envelope order.

Aliases of expanded the sender was not told about yet.

Failed recipients the sender has not been told about, with their details.

Delivered recipients whose delivery the sender asked to know about (NOTIFY=SUCCESS, or report in the details unless NOTIFY=NEVER) and was not told yet, with their details. Only those with an action in their details: the others went to a server that tells the sender itself.

Recipients with status, in envelope order.

Types

recipient()

@type recipient() :: %{
  status: :pending | Sovite.Queue.Record.status(),
  details: Sovite.Queue.Record.details() | nil,
  notified: boolean()
}

The state of one recipient.

t()

@type t() :: %Sovite.Queue.Entry{
  attempts: non_neg_integer(),
  envelope: Sovite.Queue.Envelope.t(),
  expansions: %{required(String.t()) => boolean()},
  next_attempt: DateTime.t() | nil,
  recipients: %{required(String.t()) => recipient()},
  warned: boolean()
}

Functions

apply_record(entry, arg2)

@spec apply_record(t(), Sovite.Queue.Record.t()) :: t()

Applies one record. Records for unknown recipients are ignored.

done?(entry)

@spec done?(t()) :: boolean()

Returns true when every recipient is delivered or failed.

new(envelope, records \\ [])

Builds the state from an envelope and its records.

notify?(entry, address, kind)

@spec notify?(t(), String.t(), :failure | :delay | :success | :relay) :: boolean()

Whether a notification of kind is due for address by its NOTIFY parameter (RFC 3461 §4.1). Without one, failures and delays are reported, and successes are not. :relay is anything but NEVER.

pending(entry)

@spec pending(t()) :: [String.t()]

Recipients still to be delivered (pending or deferred), in envelope order.

unnotified_expansions(entry)

@spec unnotified_expansions(t()) :: [String.t()]

Aliases of expanded the sender was not told about yet.

unnotified_failures(entry)

@spec unnotified_failures(t()) :: [{String.t(), Sovite.Queue.Record.details()}]

Failed recipients the sender has not been told about, with their details.

unnotified_successes(entry)

@spec unnotified_successes(t()) :: [{String.t(), Sovite.Queue.Record.details()}]

Delivered recipients whose delivery the sender asked to know about (NOTIFY=SUCCESS, or report in the details unless NOTIFY=NEVER) and was not told yet, with their details. Only those with an action in their details: the others went to a server that tells the sender itself.

with_status(entry, statuses)

@spec with_status(
  t(),
  Sovite.Queue.Record.status()
  | :pending
  | [Sovite.Queue.Record.status() | :pending]
) :: [String.t()]

Recipients with status, in envelope order.