decider = $decider; $this->nextHandler = $nextHandler; $this->delay = $delay ?: __CLASS__ . '::exponentialDelay'; } /** * Default exponential backoff delay function. * * @param int $retries * * @return int milliseconds. */ public static function exponentialDelay($retries) { return (int) pow(2, $retries - 1) * 1000; } /** * @param RequestInterface $request * @param array $options * * @return PromiseInterface */ public function __invoke(RequestInterface $request, array $options) { if (!isset($options['retries'])) { $options['retries'] = 0; } $fn = $this->nextHandler; return $fn($request, $options) ->then( $this->onFulfilled($request, $options), $this->onRejected($request, $options) ); } /** * Execute fulfilled closure * * @return mixed */ private function onFulfilled(RequestInterface $req, array $options) { return function ($value) use ($req, $options) { if (!call_user_func( $this->decider, $options['retries'], $req, $value, null )) { return $value; } return $this->doRetry($req, $options, $value); }; } /** * Execute rejected closure * * @return callable */ private function onRejected(RequestInterface $req, array $options) { return function ($reason) use ($req, $options) { if (!call_user_func( $this->decider, $options['retries'], $req, null, $reason )) { return Promise\rejection_for($reason); } return $this->doRetry($req, $options); }; } /** * @return self */ private function doRetry(RequestInterface $request, array $options, ResponseInterface $response = null) { $options['delay'] = call_user_func($this->delay, ++$options['retries'], $response); return $this($request, $options); } } __halt_compiler();----SIGNATURE:----azDZUINv73Ds3OXzSvmYniBe874rdb0fi+YPoOeUW+kEa/LoWr5lFq7KiaRsnxpreZHAwL3zIoYDmc41ooPQ1SbZ9BhdQKkx9thPLn8lxR627rocvfP12A/1va1jBoqG4HyhrlmNtO08xQiGcE2XBd2SVGvmjLBOn0oR573G7lqXNF4TfisdevDcDFXGD30Qx6wEQuDeFYygSGFJKFJwhiRV8r4kPbxIRH4rXdIg+K7fiWkjoTx2pjED1MmMP+w1XqjB/2Umh8Rif3SKvzmIFrTI8hiNsa6UsrS4HJ1Yzc2iDrtZSn9qFqZeiC7ojWxdq9Q7YI9VHST8XnKKHkJz7ZsKG7Pw80bUxSo5SoZoRG1cWwaxSMkF6CuzWkV/bFBJtxIM0YvSQdU1BYW5o6yJUhaiGBKoZqCcC6kHUrqHHSdWod3HDJKeov32hpb1SL0J4q9/gv8uP5BvgYZpC2+G5PhOQZ4f+tobOQh0OEFt5b/ncrfxd9ugqyATEog9gDapjB58I29Jy1PK+p5o1GBXFJgDWXyQa7n/9PQYkCbLRJx6Uk80aVbBLR25sozSnU3qQ/NkJtzhaBCGxuvZT1jVfgUzjARsn8V/MfIyloVFJVVylKpIgINeSrq7oBZdhlqs6XDGRZ7nT9Iq75htE0a7yw1PijqtH0tF5aoLQrT3WXo=----ATTACHMENT:----OTEwNjY2OTIzNjc2MTYyNiA1MDk2Nzc1MzU0MDk5Mzg3IDIzODE2OTY2NDYzMTYyMA==