Emulated timeouts for synchronous operations.
PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test/suite
.gitattributes
.gitignore
.travis.env
.travis.install
.travis.key
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
LICENSE.md
README.md
composer.json
composer.lock

README.md

Interlude

Build Status Test Coverage SemVer

Interlude is a small PHP library for repeating a non-blocking operation until it succeeds, a timeout period is reached, or a maximum number of attempts have been performed.

If you don't need the timeout feature, you might want to try igorw/retry.

Example

use Icecave\Interlude\Exception\AttemptsExhaustedException;
use Icecave\Interlude\Exception\TimeoutException;
use Icecave\Interlude\Invoker;

$invoker = new Invoker;

$operation = function ($remainingTimeout, $remainingAttempts) {
    // do work ...
};

try {
    $invoker->invoke(
        $operation,
        10, // ten second timeout
        3   // maximum of three attempts
    );
} catch (TimeoutException $e) {
    echo 'The operation timed out!' . PHP_EOL;
} catch (AttemptsExhaustedException $e) {
    echo 'The operation was attempted the maximum number of times!' . PHP_EOL;
}

Contact us