You are here

public static function Middleware::retry in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/guzzle/src/Middleware.php \GuzzleHttp\Middleware::retry()

Middleware that retries requests based on the boolean result of invoking the provided "decider" function.

If no delay function is provided, a simple implementation of exponential backoff will be utilized.

Parameters

callable $decider Function that accepts the number of retries,: a request, [response], and [exception] and returns true if the request is to be retried.

callable $delay Function that accepts the number of retries and: returns the number of milliseconds to delay.

Return value

callable Returns a function that accepts the next handler.

File

vendor/guzzlehttp/guzzle/src/Middleware.php, line 167

Class

Middleware
Functions used to create and wrap handlers with handler middleware.

Namespace

GuzzleHttp

Code

public static function retry(callable $decider, callable $delay = null) {
  return function (callable $handler) use ($decider, $delay) {
    return new RetryMiddleware($decider, $handler, $delay);
  };
}