Skip to content
This repository has been archived by the owner on Oct 8, 2018. It is now read-only.
/ retry Public archive

Retry class to re run code on retryable conditions, based on exceptions

License

Notifications You must be signed in to change notification settings

ChristianRiesen/retry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Retry

PHP class for retrying code pieces in case of exceptions.

Build Status

Born out of a need of Tobias Schultze and myself for a project at Liip which then found a specific merge request into Doctrine. But we thought this works just as well on a generic basis, hence why I built this. Most code is Tobias, I just wrapped it up into this digestible package.

Usage

Make sure it's autoloaded. Wrap the code you want retried with the class and execute it.

use ChristianRiesen\Retry\Retry;

// Anon function
$retry = new Retry(function () { return 42; });

// Outputs 42
echo $retry();

You can configure the exceptions to listen to for retries, the number of retries and the time between retries (in milliseconds) at construction time of the Retry class.

By default it will catch all exceptions

Development

To run tests, install composer, run composer install (or wherever you have composer installed) then run vendor/phpunit/phpunit/phpunit

About

Retry class to re run code on retryable conditions, based on exceptions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages