Пример #1
0
 /** @internal */
 public static function _applyRetryConfig($value, array &$args, HandlerList $list)
 {
     if (!$value) {
         return;
     }
     $list->appendSign(Middleware::retry(RetryMiddleware::createDefaultDecider($value), function ($retries) {
         return $retries ? RetryMiddleware::exponentialDelay($retries) / 2 : 0;
     }, isset($args['stats']['retries']) ? (bool) $args['stats']['retries'] : false), 'retry');
 }
Пример #2
0
 /** @internal */
 public static function _applyRetryConfig($value, $_, HandlerList $list)
 {
     if (!$value) {
         return;
     }
     $decider = RetryMiddleware::createDefaultDecider($value);
     $decider = function ($retries, $command, $request, $result, $error) use($decider, $value) {
         $maxRetries = null !== $command['@retries'] ? $command['@retries'] : $value;
         if ($decider($retries, $command, $request, $result, $error)) {
             return true;
         } elseif ($error instanceof AwsException && $retries < $maxRetries) {
             if ($error->getResponse() && $error->getResponse()->getStatusCode() >= 400) {
                 return strpos($error->getResponse()->getBody(), 'Your socket connection to the server') !== false;
             } elseif ($error->getPrevious() instanceof RequestException) {
                 // All commands except CompleteMultipartUpload are
                 // idempotent and may be retried without worry if a
                 // networking error has occurred.
                 return $command->getName() !== 'CompleteMultipartUpload';
             }
         }
         return false;
     };
     $delay = [RetryMiddleware::class, 'exponentialDelay'];
     $list->appendSign(Middleware::retry($decider, $delay), 'retry');
 }
Пример #3
0
 public static function _apply_user_agent($value, array &$args, HandlerList $list)
 {
     if (!is_array($value)) {
         $value = [$value];
     }
     $value = array_map('strval', $value);
     array_unshift($value, 'aws-sdk-php/' . Sdk::VERSION);
     $args['ua_append'] = $value;
     $list->appendBuild(static function (callable $handler) use($value) {
         return function (CommandInterface $command, RequestInterface $request) use($handler, $value) {
             return $handler($command, $request->withHeader('User-Agent', implode(' ', array_merge($value, $request->getHeader('User-Agent')))));
         };
     });
 }
Пример #4
0
 private function addInvocationId()
 {
     // Add invocation id to each request
     $this->handlerList->prependSign(Middleware::invocationId(), 'invocation-id');
 }