icecave / interlude
Emulated timeouts for synchronous operations.
Installs: 36 622
Dependents: 1
Suggesters: 0
Security: 0
Stars: 5
Watchers: 4
Forks: 0
Open Issues: 1
Requires
- php: >=5.3
- icecave/isolator: ~3
Requires (Dev)
- eloquent/phony: ~0.1.0@dev
- icecave/archer: ~1
This package is auto-updated.
Last update: 2024-10-06 12:02:34 UTC
README
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.
- Install via Composer package icecave/interlude
- Read the API documentation
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
- Follow @IcecaveStudios on Twitter
- Visit the Icecave Studios website
- Join
#icecave
on irc.freenode.net