class MiddlewareFactory in Lockr 7.3
Hierarchy
- class \Lockr\Guzzle\MiddlewareFactory
Expanded class hierarchy of MiddlewareFactory
File
- vendor/
lockr/ lockr/ src/ Guzzle/ MiddlewareFactory.php, line 10
Namespace
Lockr\GuzzleView source
class MiddlewareFactory {
/**
* @return callable
*/
public static function retry() {
return GuzzleHttp\Middleware::retry(self::retryDecider(), self::retryDelay());
}
/**
* @return callable
*/
private static function retryDelay() {
return function ($retries) {
return 1000 * $retries + mt_rand(0, 300);
};
}
/**
* @return callable
*/
private static function retryDecider() {
return function ($retries, RequestInterface $req, ResponseInterface $resp = null, RequestException $ex = null) {
if ($retries >= 5) {
return false;
}
if ($ex instanceof ConnectException) {
return true;
}
if ($resp) {
if ($resp
->getStatusCode() >= 500) {
return true;
}
}
return false;
};
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MiddlewareFactory:: |
public static | function | ||
MiddlewareFactory:: |
private static | function | ||
MiddlewareFactory:: |
private static | function |