mule/jobs/backoff

Types

pub type ExponentialOptions {
  ExponentialOptions(max_pow: Int, min_pad: Int, mult: Int)
}

Constructors

  • ExponentialOptions(max_pow: Int, min_pad: Int, mult: Int)
pub type JitterMode {
  Increment
  Decrement
  Both
}

Constructors

  • Increment
  • Decrement
  • Both
pub type JitterOptions {
  JitterOptions(mode: JitterMode, mult: Float)
}

Constructors

pub type Retries {
  InfiniteRetries
  FiniteRetries(limit: Int)
}

Constructors

  • InfiniteRetries
  • FiniteRetries(limit: Int)
pub type RetryOptions {
  RetryOptions(retries: Retries, mult: Int)
}

Constructors

  • RetryOptions(retries: Retries, mult: Int)

Values

pub const default_exponential_options: ExponentialOptions
pub const default_jitter_options: JitterOptions
pub const default_retry_options: RetryOptions

Elixir’s defaults: infinite retries, @retry_mult 100 (ms), so sleeps run 200ms up to ~102s (2^10 clamp) with ±10% jitter. mult is a field (rather than Elixir’s compile-env @retry_mult) so tests can shrink the sleeps.

pub fn exponential(
  attempt attempt: Int,
  options options: ExponentialOptions,
) -> Int
pub fn jitter(
  backoff_amount time: Int,
  options jitter_options: JitterOptions,
) -> Int
pub fn jitter_with(
  backoff_amount time: Int,
  randomness randomness: Float,
  options jitter_options: JitterOptions,
) -> Int
pub fn with_retry(
  run run: fn() -> Result(value, engine.EngineError),
  options options: RetryOptions,
) -> Result(value, engine.EngineError)

Attempt an engine interaction repeatedly until it succeeds or retries are exhausted (backoff.ex with_retry/2). Retryable classes, the typed analog of DBConnection/Postgrex errors + GenServer timeouts:

  • Error(EngineFailure(_)) results (connection-level failures), and
  • crashes out of run (in-memory actor call timeout/callee-down panics), re-raised with the original stacktrace on exhaustion. Error(JobNotFound(_)) and Error(JobLockedOrNotFound(_)) are domain-shaped and return immediately.
Search Document