Tolerance\Operation\Runner\RetryOperationRunner::run PHP Method

run() public method

public run ( Tolerance\Operation\Operation $operation )
$operation Tolerance\Operation\Operation
    public function run(Operation $operation)
    {
        if ($this->waitStrategy instanceof StatefulWaiter) {
            $this->waitStrategy->resetState();
        }
        return $this->runOperation($operation);
    }

Usage Example

Example #1
0
 /**
  * Add fault tolerance to the request.
  *
  * @param string|array $request
  *
  * @return array
  */
 protected function sendWithTolerance($request)
 {
     $operation = new Callback(function () use($request) {
         return $request->send();
     });
     // Creates the strategy used to wait between failing calls
     $waitStrategy = new CountLimited(new ExponentialBackOff(new SleepWaiter(), $request->timeUntilNextTry), $request->triesUntilFailure);
     // Creates the runner
     $runner = new RetryOperationRunner(new CallbackOperationRunner(), $waitStrategy);
     return $runner->run($operation);
 }
All Usage Examples Of Tolerance\Operation\Runner\RetryOperationRunner::run