Kombu.Utils.Retry (Kombu v0.1.0)

Copy Markdown View Source

Functional utilities, LRU cache, and retry helpers matching kombu.utils.functional and kombu.utils.time.

Summary

Functions

Remove all keys from a map or keyword list whose value is nil.

Generate floating-point range (kombu.utils.functional.fxrange).

Generate floating-point range bounded by cumulative sum max (kombu.utils.functional.fxrangemax).

Wrap a scalar in a single-element list unless it is nil or already a list.

Convert seconds to milliseconds (int(float(v) * 1000.0)), or nil if nil.

Retry fun when an exception in catch_list is raised (kombu.utils.functional.retry_over_time).

Functions

dictfilter(map_or_kw)

@spec dictfilter(map() | keyword()) :: map()

Remove all keys from a map or keyword list whose value is nil.

fxrange(start \\ 1.0, stop \\ nil, step \\ 1.0, repeatlast \\ false)

@spec fxrange(number(), number() | nil, number(), boolean()) :: Enumerable.t()

Generate floating-point range (kombu.utils.functional.fxrange).

fxrangemax(start \\ 1.0, stop \\ nil, step \\ 1.0, max \\ 100.0)

@spec fxrangemax(number(), number() | nil, number(), number()) :: Enumerable.t()

Generate floating-point range bounded by cumulative sum max (kombu.utils.functional.fxrangemax).

maybe_list(list)

@spec maybe_list(term()) :: list() | nil

Wrap a scalar in a single-element list unless it is nil or already a list.

maybe_s_to_ms(v)

@spec maybe_s_to_ms(number() | nil) :: integer() | nil

Convert seconds to milliseconds (int(float(v) * 1000.0)), or nil if nil.

retry_over_time(fun, catch_exceptions, opts \\ [])

@spec retry_over_time((-> term()), module() | [module()], keyword()) :: term()

Retry fun when an exception in catch_list is raised (kombu.utils.functional.retry_over_time).

Options:

  • :max_retries - maximum number of retries before re-raising (nil for unlimited)
  • :interval_start - initial backoff in seconds (default 2)
  • :interval_step - backoff increment in seconds (default 2)
  • :interval_max - maximum sleep interval in seconds (default 30)
  • :errback - fn exc, interval_list, retries -> sleep_seconds
  • :callback - fn -> :ok called between retries and each 1s sleep tick
  • :timeout - overall timeout in seconds (nil for none)
  • :sleep_fn - custom sleep function fn seconds -> :ok (defaults to Process.sleep(trunc(s * 1000)))