Google\Cloud\ExponentialBackoff::setDelayFunction PHP Method

setDelayFunction() public method

public setDelayFunction ( callable $delayFunction ) : void
$delayFunction callable
return void
    public function setDelayFunction(callable $delayFunction)
    {
        $this->delayFunction = $delayFunction;
    }

Usage Example

 public function testSuccessWithNoRetries()
 {
     $actualAttempts = 0;
     $backoff = new ExponentialBackoff();
     $backoff->setDelayFunction($this->delayFunction);
     $backoff->execute(function () use(&$actualAttempts) {
         $actualAttempts++;
         return;
     });
     $this->assertEquals(1, $actualAttempts);
 }