Sovite.Queue.Entry (sovite v0.2.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.

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.

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

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

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(),
  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.

pending(entry)

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

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

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.

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.