Liking cljdoc? Tell your friends :D

net.modulolotus.truegrit.retry

Implements retries, which call a fn again when it fails (up to a limit).

See https://resilience4j.readme.io/docs/retry

Implements retries, which call a fn again when it fails (up to a limit).

See https://resilience4j.readme.io/docs/retry
raw docstring

*default-config*clj

Set this to override the R4j defaults with your own

Set this to override the R4j defaults with your own
sourceraw docstring

add-listenersclj

(add-listeners rt
               {:keys [on-event on-retry on-success on-error on-ignored-error]})

Add event handlers for Retry lifecycle events. Note that a call that succeeds on the first try will generate no events.

Config map options:

  • :on-event - a handler that runs for all events
  • :on-retry - a handler that runs after a retry - receives a RetryOnRetryEvent
  • :on-success - a handler that runs after a successful retry (NOT a successful initial call) - receives a RetryOnSuccessEvent
  • :on-error - a handler that runs after an error and there are no retries left - receives a RetryOnErrorEvent
  • :on-ignored-error - a handler that runs after an error was ignored - receives a RetryOnIgnoredErrorEvent
Add event handlers for Retry lifecycle events. Note that a call that succeeds on the first
try will generate no events.

Config map options:
 - `:on-event` - a handler that runs for all events
 - `:on-retry` - a handler that runs after a retry - receives a RetryOnRetryEvent
 - `:on-success` - a handler that runs after a successful retry (NOT a successful initial call) - receives a RetryOnSuccessEvent
 - `:on-error` - a handler that runs after an error and there are no retries left - receives a RetryOnErrorEvent
 - `:on-ignored-error` - a handler that runs after an error was ignored - receives a RetryOnIgnoredErrorEvent
sourceraw docstring

metricsclj

(metrics rt)

Returns metrics for the given retry.

Numbers are for overall success of a call, not the underlying number of calls. E.g., if it's set to retry up to 5 times, and a call fails 4 times and succeeds on the last, that only increments :number-of-successful-calls-with-retry-attempt by 1.

Returns metrics for the given retry.

Numbers are for overall success of a call, not the underlying number of calls.
E.g., if it's set to retry up to 5 times, and a call fails 4 times and succeeds
on the last, that only increments `:number-of-successful-calls-with-retry-attempt`
by 1.
sourceraw docstring

retrieveclj

(retrieve f)

Retrieves a retry from a wrapped fn

Retrieves a retry from a wrapped fn
sourceraw docstring

retryclj

(retry retry-name config)

Creates a Retry with the given name and config.

Creates a Retry with the given name and config.
sourceraw docstring

retry-configclj

(retry-config config)

Creates a Resilience4j RetryConfig.

Config map options

  • :max-attempts - # of times to try - defaults to 3
  • :wait-duration - how long to wait after failure before trying a call again - defaults to 500 ms - accepts number of ms or java.time.Duration
  • :interval-function - either a 1-arity fn that takes in the number of attempts so far (from 1 to n) and returns the number of ms to wait, or an instance of io.github.resilience4j.core.IntervalFunction (see IntervalFunction for useful fns that build common wait strategies like exponential backoff)

Less common config map options

  • :ignore-exceptions - a coll of Throwables to ignore - e.g., [IrrelevantException IgnoreThisException] - (includes subclasses of the Throwables, too)
  • :retry-exceptions - a coll of Throwables to retry on - defaults to all - :ignore-exceptions takes precedence over this
  • :retry-on-exception - a 1-arg fn that tests a Throwable and returns true if it should be retried
  • :retry-on-result - a 1-arg fn that tests the result and returns true if it should be retried
  • :fail-after-max-attempts? - If :retry-on-result is set, should it throw a MaxRetriesExceededException if it reached the maximum number of attempts, but the retry-on-result predicate is still true? - defaults to false
  • :interval-bi-function - a 2-arity fn that takes in the number of attempts so far (from 1 to n) and either a Throwable or a result - returns the number of ms to wait - should only be used when :retry-on-result is also set

WARNING: :wait-duration, :interval-function, and :interval-bi-function conflict. Trying to set more than one will throw an exception.

Creates a Resilience4j RetryConfig.

Config map options
 - `:max-attempts` - # of times to try - defaults to 3
 - `:wait-duration` - how long to wait after failure before trying a call again - defaults to 500 ms - accepts number of ms or java.time.Duration
 - `:interval-function` - either a 1-arity fn that takes in the number of attempts so far (from 1 to n) and returns the number of ms to wait,
        or an instance of io.github.resilience4j.core.IntervalFunction (see IntervalFunction for useful fns that build common wait strategies
        like exponential backoff)

Less common config map options
 - `:ignore-exceptions` - a coll of Throwables to ignore - e.g., [IrrelevantException IgnoreThisException] - (includes subclasses of the Throwables, too)
 - `:retry-exceptions` - a coll of Throwables to retry on - defaults to all - `:ignore-exceptions` takes precedence over this
 - `:retry-on-exception` - a 1-arg fn that tests a Throwable and returns true if it should be retried
 - `:retry-on-result` - a 1-arg fn that tests the result and returns true if it should be retried
 - `:fail-after-max-attempts?` - If :retry-on-result is set, should it throw a MaxRetriesExceededException if it reached the maximum number of attempts, but the retry-on-result predicate is still true? - defaults to false
 - `:interval-bi-function` - a 2-arity fn that takes in the number of attempts so far (from 1 to n) and either a Throwable or a result - returns
        the number of ms to wait - should only be used when `:retry-on-result` is also set

WARNING: `:wait-duration`, `:interval-function`, and `:interval-bi-function` conflict. Trying to set more than one will throw an exception.
sourceraw docstring

wrapclj

(wrap f rt)

Wraps a function in a Retry. If the max # of retries is exceeded, throws the last Exception received, or MaxRetriesExceeded if errors didn't involve Exceptions.

Attaches the retry as metadata on the wrapped fn at :truegrit/retry

Wraps a function in a Retry. If the max # of retries is exceeded, throws the last Exception received,
or MaxRetriesExceeded if errors didn't involve Exceptions.

Attaches the retry as metadata on the wrapped fn at :truegrit/retry
sourceraw docstring

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

× close