PHP code example of netlogix / retry

1. Go to this page and download the library: Download netlogix/retry library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

netlogix / retry example snippets


(new \Netlogix\Retry\Retry())
    ->when(condition: fn(int $incarnation) => $incarnation < PHP_INT_MAX)
    ->task(subject: fn () => throw new \RuntimeException('false'));

(new \Netlogix\Retry\Retry())
    /**
     * http://backoffcalculator.com/?attempts=5&rate=1&interval=0.5
     * = (0.5 + 1 + 1.5 + 2.0 + 2.5) seconds
     * = 7.5 seconds
     */
    ->withExponentialBackoff(retryInterval: 0.5, maxRetries: 5)
    ->onExceptionsOfType(\Doctrine\DBAL\Exception\DeadlockException::class)
    ->task(fn () => $dbal->executeQuery($statement));