Download the PHP package s-patompong/php-retrier without Composer
On this page you can find all versions of the php package s-patompong/php-retrier. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download s-patompong/php-retrier
More information about s-patompong/php-retrier
Files in s-patompong/php-retrier
Package php-retrier
Short Description PHP Retrier lets you retry your logic easily.
License MIT
Homepage https://github.com/s-patompong/php-retrier
Informations about the package php-retrier
PHP Retrier
Retrier can help you retry your logic easily.
Installation
You can install the package via composer:
Usage
Fields and their default values:
Field | Description | Setter | Default |
---|---|---|---|
delay | Wait time between each retry | setDelay(int $delay): Retrier | 3 |
retryTimes | Number of retry | setRetryTimes(int $retryTimes): Retrier | 3 |
onRetryListener | A closure that will be called on retry | setOnRetryListener(function(int $currentTryTimes, ?mixed $returnedValue, ?\Throwable $throwable): void {}): Retrier | null |
retryStrategy | A class that implement RetryStrategy interface | setRetryStrategy(RetryStrategy $retryStrategy): Retrier | null |
Minimal configuration example:
Full configuration example:
It's also possible to use callable array syntax when set the logic or retryListener:
Retry Strategy
RetryStrategy is a class that implement RetryStrategy interface. The Retrier class uses it to determine if it should retry or not (given the return value from the logic).
This library provides two presets strategy:
RetryThrowableStrategy
- This is a default strategy that will retry any \Throwable response.RetryNullStrategy
- This strategy will keep retry if the response is NULL.
If you want to have a custom shouldRetry()
logic, you can create your own RetryStrategy class and implement this RetryStrategy interface.
Then, set it as a retry strategy of the Retrier:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Patompong Savaengsuk
- All Contributors
License
The MIT License (MIT). Please see License File for more information.