Laravel version update
Laravel version update
This commit is contained in:
70
vendor/aws/aws-sdk-php/src/RetryMiddleware.php
vendored
70
vendor/aws/aws-sdk-php/src/RetryMiddleware.php
vendored
@@ -2,11 +2,10 @@
|
||||
namespace Aws;
|
||||
|
||||
use Aws\Exception\AwsException;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use GuzzleHttp\Promise;
|
||||
use GuzzleHttp\Promise\PromiseInterface;
|
||||
use GuzzleHttp\Psr7;
|
||||
use GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
* @internal Middleware that retries failures.
|
||||
@@ -25,9 +24,11 @@ class RetryMiddleware
|
||||
'RequestLimitExceeded' => true,
|
||||
'Throttling' => true,
|
||||
'ThrottlingException' => true,
|
||||
'ThrottledException' => true,
|
||||
'ProvisionedThroughputExceededException' => true,
|
||||
'RequestThrottled' => true,
|
||||
'BandwidthLimitExceeded' => true,
|
||||
'RequestThrottledException' => true,
|
||||
];
|
||||
|
||||
private $decider;
|
||||
@@ -56,13 +57,18 @@ class RetryMiddleware
|
||||
*/
|
||||
public static function createDefaultDecider($maxRetries = 3)
|
||||
{
|
||||
$retryCurlErrors = [];
|
||||
if (extension_loaded('curl')) {
|
||||
$retryCurlErrors[CURLE_RECV_ERROR] = true;
|
||||
}
|
||||
|
||||
return function (
|
||||
$retries,
|
||||
CommandInterface $command,
|
||||
RequestInterface $request,
|
||||
ResultInterface $result = null,
|
||||
$error = null
|
||||
) use ($maxRetries) {
|
||||
) use ($maxRetries, $retryCurlErrors) {
|
||||
// Allow command-level options to override this value
|
||||
$maxRetries = null !== $command['@retries'] ?
|
||||
$command['@retries']
|
||||
@@ -70,19 +76,47 @@ class RetryMiddleware
|
||||
|
||||
if ($retries >= $maxRetries) {
|
||||
return false;
|
||||
} elseif (!$error) {
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
return isset(self::$retryStatusCodes[$result['@metadata']['statusCode']]);
|
||||
} elseif (!($error instanceof AwsException)) {
|
||||
return false;
|
||||
} elseif ($error->isConnectionError()) {
|
||||
return true;
|
||||
} elseif (isset(self::$retryCodes[$error->getAwsErrorCode()])) {
|
||||
return true;
|
||||
} elseif (isset(self::$retryStatusCodes[$error->getStatusCode()])) {
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!($error instanceof AwsException)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($error->isConnectionError()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isset(self::$retryCodes[$error->getAwsErrorCode()])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isset(self::$retryStatusCodes[$error->getStatusCode()])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (count($retryCurlErrors)
|
||||
&& ($previous = $error->getPrevious())
|
||||
&& $previous instanceof RequestException
|
||||
) {
|
||||
if (method_exists($previous, 'getHandlerContext')) {
|
||||
$context = $previous->getHandlerContext();
|
||||
return !empty($context['errno'])
|
||||
&& isset($retryCurlErrors[$context['errno']]);
|
||||
}
|
||||
|
||||
$message = $previous->getMessage();
|
||||
foreach (array_keys($retryCurlErrors) as $curlError) {
|
||||
if (strpos($message, 'cURL error ' . $curlError . ':') === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -91,13 +125,15 @@ class RetryMiddleware
|
||||
*
|
||||
* Exponential backoff with jitter, 100ms base, 20 sec ceiling
|
||||
*
|
||||
* @param $retries
|
||||
* @param $retries - The number of retries that have already been attempted
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @link https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
|
||||
*/
|
||||
public static function exponentialDelay($retries)
|
||||
{
|
||||
return mt_rand(0, (int) min(20000, (int) pow(2, $retries - 1) * 100));
|
||||
return mt_rand(0, (int) min(20000, (int) pow(2, $retries) * 100));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +168,7 @@ class RetryMiddleware
|
||||
|
||||
if ($value instanceof \Exception || $value instanceof \Throwable) {
|
||||
if (!$decider($retries, $command, $request, null, $value)) {
|
||||
return \GuzzleHttp\Promise\rejection_for(
|
||||
return Promise\rejection_for(
|
||||
$this->bindStatsToReturn($value, $requestStats)
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user