Step-level retry with an optional pre-retry hook.
A step declares retry behaviour under its :retry key:
:retry {:max 2
:on_code [:unauthorized]
:before_retry {:key "cmap-token-refresh"}}
The hook is called before each retry attempt with a failure-context map; its return value replaces the request-ctx used for the next call. Common use case: refresh a bearer token and inject it into the Authorization header before the retry.
Step-level retry with an optional pre-retry hook.
A step declares retry behaviour under its `:retry` key:
:retry {:max 2
:on_code [:unauthorized]
:before_retry {:key "cmap-token-refresh"}}
The hook is called before each retry attempt with a failure-context map;
its return value replaces the request-ctx used for the next call. Common
use case: refresh a bearer token and inject it into the Authorization
header before the retry.(apply-before-retry retry-cfg failure-context retry-hooks)Run the before-retry hook if declared, resolving it against retry-hooks
(a map "key" → impl). Returns the request-ctx to use for the next
attempt — either the hook's return value or the current ctx.
Run the before-retry hook if declared, resolving it against `retry-hooks` (a map "key" → impl). Returns the request-ctx to use for the next attempt — either the hook's return value or the current ctx.
(before-retry this failure-context)Called before a retry attempt. failure-context has :step-id, :attempt
(1-indexed retry number), :args, :chain-ctx, :request-ctx, :error.
Return a request-ctx map to use for the retry, or nil to reuse the
current one.
Called before a retry attempt. `failure-context` has :step-id, :attempt (1-indexed retry number), :args, :chain-ctx, :request-ctx, :error. Return a request-ctx map to use for the retry, or nil to reuse the current one.
(should-retry? retry-cfg result attempt)True if the step is configured to retry, the result is an error, its code
is in the allowlist, and the retry budget isn't exhausted. attempt is
the count of retries already made (0 = the first call just failed).
True if the step is configured to retry, the result is an error, its code is in the allowlist, and the retry budget isn't exhausted. `attempt` is the count of retries already made (0 = the first call just failed).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |