Google\Cloud\RequestWrapper::getRetryFunction PHP Méthode

getRetryFunction() private méthode

Determines whether or not the request should be retried.
private getRetryFunction ( ) : boolean
Résultat boolean
    private function getRetryFunction()
    {
        $httpRetryCodes = $this->httpRetryCodes;
        $httpRetryMessages = $this->httpRetryMessages;
        return function (\Exception $ex) use($httpRetryCodes, $httpRetryMessages) {
            $statusCode = $ex->getCode();
            if (in_array($statusCode, $httpRetryCodes)) {
                return true;
            }
            $message = json_decode($ex->getMessage(), true);
            if (!isset($message['error']['errors'])) {
                return false;
            }
            foreach ($message['error']['errors'] as $error) {
                if (in_array($error['reason'], $httpRetryMessages)) {
                    return true;
                }
            }
            return false;
        };
    }