Google\Cloud\ExponentialBackoff::execute PHP Метод

execute() публичный Метод

Executes the retry process.
public execute ( callable $function, array $arguments = [] ) : mixed
$function callable
$arguments array [optional]
Результат mixed
    public function execute(callable $function, array $arguments = [])
    {
        $delayFunction = $this->delayFunction;
        $retryAttempt = 0;
        $exception = null;
        while (true) {
            try {
                return call_user_func_array($function, $arguments);
            } catch (\Exception $exception) {
                if ($this->retryFunction) {
                    if (!call_user_func($this->retryFunction, $exception)) {
                        throw $exception;
                    }
                }
                if ($retryAttempt >= $this->retries) {
                    break;
                }
                $delayFunction($this->calculateDelay($retryAttempt));
                $retryAttempt++;
            }
        }
        throw $exception;
    }

Usage Example

 public static function tearDownFixtures()
 {
     $backoff = new ExponentialBackoff(8);
     foreach (self::$deletionQueue as $item) {
         $backoff->execute(function () use($item) {
             $item->delete();
         });
     }
 }
All Usage Examples Of Google\Cloud\ExponentialBackoff::execute