/** @internal */
 public static function _applyRetryConfig($value, array &$args, HandlerList $list)
 {
     if (!$value) {
         return;
     }
     $list->appendSign(Middleware::retry(RetryMiddleware::createDefaultDecider($value), function ($retries) {
         return $retries ? 50 * (int) pow(2, $retries - 1) / 1000 : 0;
     }), 'retry');
 }
 /** @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');
 }
 public function __construct(array $args)
 {
     parent::__construct($args);
     // Setup middleware.
     $stack = $this->getHandlerList();
     $stack->appendBuild($this->getApiVersionMiddleware(), 'glacier.api_version');
     $stack->appendBuild($this->getChecksumsMiddleware(), 'glacier.checksum');
     $stack->appendBuild(Middleware::contentType(['UploadArchive', 'UploadPart']), 'glacier.content_type');
     $stack->appendInit(Middleware::sourceFile($this->getApi(), 'body', 'sourceFile'), 'glacier.source_file');
 }
Exemple #4
0
 public function createS3($args = [])
 {
     if ($this->_s3 === null) {
         $this->_s3 = $this->getSdk()->createS3($args);
         $this->_s3->getHandlerList()->prependInit(Middleware::tap(function ($cmd, $req) {
             if ($this->bucket) {
                 $cmd['Bucket'] = $this->bucket;
             }
         }));
     }
     return $this->_s3;
 }
Exemple #5
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');
 }
 /** @internal */
 public static function _applyRetryConfig($value, $_, HandlerList $list)
 {
     if (!$value) {
         return;
     }
     $decider = RetryMiddleware::createDefaultDecider($value);
     $decider = function ($retries, $request, $result, $error) use($decider) {
         if ($decider($retries, $request, $result, $error)) {
             return true;
         } elseif ($error instanceof AwsException) {
             return $error->getResponse() && strpos($error->getResponse()->getBody(), 'Your socket connection to the server') !== false;
         }
         return false;
     };
     $delay = [RetryMiddleware::class, 'exponentialDelay'];
     $list->appendSign(Middleware::retry($decider, $delay), 'retry');
 }
 private function addInvocationId()
 {
     // Add invocation id to each request
     $this->handlerList->prependSign(Middleware::invocationId(), 'invocation-id');
 }
 public static function _apply_validate($value, array &$args, HandlerList $list)
 {
     if ($value === true) {
         $list->appendValidate(Middleware::validation($args['api'], new Validator()), 'validation');
     }
 }
 public static function _apply_validate($value, array &$args, HandlerList $list)
 {
     if ($value === false) {
         return;
     }
     $validator = $value === true ? new Validator() : new Validator($value);
     $list->appendValidate(Middleware::validation($args['api'], $validator), 'validation');
 }
Exemple #10
0
 private function addSignatureMiddleware()
 {
     // Sign requests. This may need to be modified later to support
     // variable signatures per/operation.
     $this->handlerList->appendSign(Middleware::signer($this->credentialProvider, constantly(SignatureProvider::resolve($this->signatureProvider, $this->config['signature_version'], $this->api->getSigningName(), $this->region))), 'signer');
 }