Spectre.Operation.Delivery (Spectre v0.3.0)

Copy Markdown View Source

Authorizes proactive delivery without performing transport I/O.

Summary

Functions

Decides whether event may be proactively delivered to destination under policy.

Promotes a due deferred or digest receipt back to :authorized.

Marks an authorized receipt as delivered, recording the external receipt and time.

Marks an authorized receipt as failed with the given reason.

Functions

authorize(event, loop, destination, policy, history, opts \\ [])

Decides whether event may be proactively delivered to destination under policy.

Returns {:ok, receipt} when delivery is authorized, deferred (quiet hours) or routed to a digest, {:duplicate, receipt} when a prior receipt in history matches the dedupe key within its TTL, and {:error, receipt} when delivery is denied; the receipt records the decision and its reason. No transport I/O occurs.

authorized(receipt, at \\ System.system_time(:millisecond))

Promotes a due deferred or digest receipt back to :authorized.

delivered(receipt, external_receipt, at \\ System.system_time(:millisecond))

Marks an authorized receipt as delivered, recording the external receipt and time.

Returns {:ok, receipt} with the updated receipt, or {:error, reason} when the transition is not allowed from the receipt's current status.

failed(receipt, reason)

Marks an authorized receipt as failed with the given reason.

Returns {:ok, receipt} with the updated receipt, or {:error, reason} when the transition is not allowed from the receipt's current status.