Liking cljdoc? Tell your friends :D

circle.wait-for8


catch-dispatchclj

(catch-dispatch options throwable)
source

catch?cljmultimethod

decides whether this exception should be caught

decides whether this exception should be caught
sourceraw docstring

duration->millisclj

(duration->millis d)
source

exception-class?clj

(exception-class? x)
source

exponential-backoff-fnclj

(exponential-backoff-fn)
(exponential-backoff-fn
  {:keys [base mult jitter seed]
   :or {base (time/millis 900) mult 1.25 jitter (time/millis 100)}})

Returns an impure function, suitable for passing as a sleep argument to wait-for, that implements an exponential back-off with optional jitter.

With no-args the delay will be ~1s initially, grow 1.25 with each retry and have 100ms of jitter

algorithm is: max(0, base * mult^n +/- (jitter/2))

n is the retry number base and jitter specified as java duration

Returns an impure function, suitable for passing as a sleep argument
to wait-for, that implements an exponential back-off with optional
jitter.

With no-args the delay will be ~1s initially, grow 1.25 with each
retry and have 100ms of jitter

algorithm is:
    max(0,
        base * mult^n +/- (jitter/2))

n is the retry number
base and jitter specified as java duration
sourceraw docstring

failclj

(fail {:keys [sleep] :as options})

stuff to do when an iteration fails. Returns new options

stuff to do when an iteration fails. Returns new options
sourceraw docstring

parse-argsclj

(parse-args args)
source

retry?clj

(retry? options)
source

success?clj

(success? options result)
source

wait-forclj

(wait-for fn)
(wait-for options fn)

Higher Order Function that controls retry behavior. By default, call f, and retry (by calling again), if f returns falsey.

  • f - a fn of no arguments.

Options:

  • sleep: how long to sleep between retries, either as a java8 duration or as a no-arg function returning a long millis value. The function will be called after each failure to retrieve a new value. A call to (exponential-backoff-fn) will create a suitable fn to implement exponential backoff with jitter strategy.

    Defaults to 1s.

  • tries: number of times to retry before throwing. An integer, or :unlimited. Defaults to 3 (or unlimited if :timeout is given, and :tries is not)

  • timeout: a java8 duration. Stop retrying when period has elapsed, regardless of how many tries are left.

  • catch: By default, wait-for does not catch exceptions. Pass this to specify which exceptions should be caught and retried Can be one of several things:

    • a seq of exception classes to catch and retry on
    • an fn of one argument, the thrown exception. Retry if it returns truthy.
    • if the exception is a slingshot throwing a map, can be a keyword, or a vector of a key and value, destructuring slingshot-style. Retry if the value obtained by destrutcturing is truthy

    If the exception matches the catch clause, wait-for retries. Otherwise the exception is thrown.

  • success-fn: a fn of one argument, the return value of f. Stop retrying if success-fn returns truthy. If not specified, wait-for returns when f returns truthy. May pass :no-throw here, which will return truthy when f doesn't throw.

  • error-hook: a fn of one argument, an exception. Called every time fn throws, before the catch clause decides what to do with the exception. This is useful for e.g. logging.

Higher Order Function that controls retry behavior. By default, call f, and retry (by calling again), if f returns falsey.

- f - a fn of no arguments.

Options:

 - sleep: how long to sleep between retries, either as a java8
   duration or as a no-arg function returning a long millis value. The function
   will be called after each failure to retrieve a new value.
   A call to (exponential-backoff-fn) will create a suitable fn
   to implement exponential backoff with jitter strategy.

   Defaults to 1s.

- tries: number of times to retry before throwing. An integer,
  or :unlimited. Defaults to 3 (or unlimited if :timeout is given, and :tries is not)

- timeout: a java8 duration. Stop retrying when period has elapsed,
  regardless of how many tries are left.

- catch: By default, wait-for does not catch exceptions. Pass this to specify which exceptions should be caught and retried
    Can be one of several things:
    - a seq of exception classes to catch and retry on
    - an fn of one argument, the thrown exception. Retry if it returns truthy.
    - if the exception is a slingshot throwing a map, can be a
      keyword, or a vector of a key and value, destructuring
      slingshot-style. Retry if the value obtained by destrutcturing is truthy

  If the exception matches the catch clause, wait-for
  retries. Otherwise the exception is thrown.

- success-fn: a fn of one argument, the return value of f. Stop
  retrying if success-fn returns truthy. If not specified, wait-for
  returns when f returns truthy. May pass :no-throw here, which will
  return truthy when f doesn't throw.

- error-hook: a fn of one argument, an exception. Called every time
  fn throws, before the catch clause decides what to do with the
  exception. This is useful for e.g. logging.
sourceraw docstring

wait-for*clj

(wait-for* {:keys [options f]})
source

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

× close