Liking cljdoc? Tell your friends :D
Clojure only.

stripe-clojure.http.retry


with-retryclj

(with-retry f max-retries)

Wraps a function with retry logic that utilizes an exponential backoff with jitter.

The provided function, f, is expected to return a map that includes a :status key. If the returned status is retryable (as determined by retryable-status?), the function will wait (using exponential backoff with jitter) and retry the operation.

The process repeats until a non-retryable status is returned or the maximum number of retries (max-retries) is reached. On each iteration, the attempt count is incremented, which influences the delay calculation.

Parameters:

  • f: A function to be executed that returns a map with at least a :status key.
  • max-retries: The maximum number of retry attempts (non-negative integer).

Returns: A new function wrapping f. When called, it will:

  1. Execute f with the provided arguments.
  2. Check if the result contains a retryable status.
  3. If retryable and the attempt count is less than max-retries, wait using the exponential backoff with jitter and retry.
  4. Otherwise, return the most recent result.
Wraps a function with retry logic that utilizes an exponential backoff with jitter.

The provided function, `f`, is expected to return a map that includes a `:status` key.
If the returned status is retryable (as determined by `retryable-status?`),
the function will wait (using exponential backoff with jitter) and retry the operation.

The process repeats until a non-retryable status is returned or the maximum number of
retries (`max-retries`) is reached. On each iteration, the attempt count is incremented,
which influences the delay calculation.

Parameters:
- f: A function to be executed that returns a map with at least a `:status` key.
- max-retries: The maximum number of retry attempts (non-negative integer).

Returns:
A new function wrapping `f`. When called, it will:
  1. Execute `f` with the provided arguments.
  2. Check if the result contains a retryable status.
  3. If retryable and the attempt count is less than `max-retries`, wait using the
     exponential backoff with jitter and retry.
  4. Otherwise, return the most recent result.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close