Karta.Outbound.RetryPolicy (Karta v1.0.0)

When a temporarily failed delivery is tried again, and when Karta gives up.

After the n-th failed attempt the next one comes delay(n) seconds later: 5, 10, 20, 40, 80 and 160 minutes, then every 4 hours. A message is given up max_age after it was queued (default 5 days; RFC 5321 §4.5.4.1 asks for at least 4-5 days). The last attempt is made at that moment, so the schedule spans the whole period; a temporary failure at or after it is final (the recipient bounces with status 4.4.7, "delivery time expired").

A rate limit is not a failure: a delivery postponed by a rate limit is not counted as an attempt (see Karta.Outbound.Deliverer).

Summary

Functions

Seconds from the attempt-th failed attempt (1, 2, ...) to the next one.

The default maximum age of a queued message, in seconds (5 days).

After attempts failed attempts, the last one at now, of a message queued at queued_at: {:retry, at} or :expired. Option: :max_age in seconds.

The whole schedule: the seconds after queueing at which a recipient that keeps failing temporarily is tried (attempts taking no time). Option: :max_age.

Functions

delay(attempt)

@spec delay(pos_integer()) :: pos_integer()

Seconds from the attempt-th failed attempt (1, 2, ...) to the next one.

max_age()

@spec max_age() :: pos_integer()

The default maximum age of a queued message, in seconds (5 days).

next_attempt(queued_at, attempts, now, opts \\ [])

@spec next_attempt(DateTime.t(), pos_integer(), DateTime.t(), keyword()) ::
  {:retry, DateTime.t()} | :expired

After attempts failed attempts, the last one at now, of a message queued at queued_at: {:retry, at} or :expired. Option: :max_age in seconds.

schedule(opts \\ [])

@spec schedule(keyword()) :: [non_neg_integer()]

The whole schedule: the seconds after queueing at which a recipient that keeps failing temporarily is tried (attempts taking no time). Option: :max_age.