ForgeOpsTracker.DeliveryStatus (forge_ops_tracker v0.20.0)

Copy Markdown View Source

What became of one delivery attempt. A bare true/false could not tell "the server will never take this payload" apart from "try again later", so a batch a plan or a validation rule refused was re-sent at every flush for as long as the node lived. Ported from gems/forge_ops_tracker's delivery_status.rb.

  • :delivered is any 2xx.
  • :rejected is a 4xx other than 408 and 429: sending the same payload again can only fail the same way.
  • :failed is a network error, a timeout, a 5xx, a 408 or a 429: worth another attempt later.

ForgeOpsTracker.Client's deliver* functions still answer a boolean (true only for :delivered); its attempt_* functions answer the status itself.

Summary

Functions

After this many flushes in a row that failed for now, a batch is dropped rather than kept for yet another attempt, so an outage can never pin the same data in memory for the life of the node.

Decides whether the batch a flush just sent is done with, given the status of the attempt and how many flushes in a row had failed before it. Returns {:release, nil} for a delivered batch, {:release, why} for one to drop (why is what to log), and {:keep, failed_flushes} for one to hold for the next flush, with the new count.

Types

t()

@type t() :: :delivered | :rejected | :failed

Functions

for_code(code)

@spec for_code(integer()) :: t()

max_failed_flushes()

@spec max_failed_flushes() :: pos_integer()

After this many flushes in a row that failed for now, a batch is dropped rather than kept for yet another attempt, so an outage can never pin the same data in memory for the life of the node.

settle(atom, failed_flushes)

@spec settle(t(), non_neg_integer()) ::
  {:release, String.t() | nil} | {:keep, pos_integer()}

Decides whether the batch a flush just sent is done with, given the status of the attempt and how many flushes in a row had failed before it. Returns {:release, nil} for a delivered batch, {:release, why} for one to drop (why is what to log), and {:keep, failed_flushes} for one to hold for the next flush, with the new count.