keboola / retry
Library for repeatable and retryable operations
Installs: 75 186
Dependents: 12
Suggesters: 0
Security: 0
Stars: 1
Watchers: 7
Forks: 2
Open Issues: 4
Requires
- php: >=7.1
- psr/log: ^1.1|^2|^3
Requires (Dev)
- keboola/coding-standard: ^7.0
- phpstan/phpstan-shim: ^0.10
- phpunit/phpunit: 7.*
Replaces
This package is auto-updated.
Last update: 2024-12-13 15:16:33 UTC
README
The library for repeatable and retryable operations.
(Forked from https://github.com/vkartaviy/retry)
Here is a simple example:
<?php use Retry\RetryProxy; use Retry\Policy\SimpleRetryPolicy; use Retry\BackOff\ExponentialBackOffPolicy; $retryPolicy = new SimpleRetryPolicy(3); $backOffPolicy = new ExponentialBackOffPolicy(); $proxy = new RetryProxy($retryPolicy, $backOffPolicy); $result = $proxy->call(function() { // call external service and return result });
If you want to supply your own retry decider method you can by using the CallableRetryPolicy
<?php use Retry\RetryProxy; use Retry\Policy\SimpleRetryPolicy; use Retry\BackOff\ExponentialBackOffPolicy; $retryPolicy = new CallableRetryPolicy(function (\Throwable $e) { if ($e->getCode() === 200) { return false; } return true; }); $proxy = new RetryProxy($retryPolicy, new ExponentialBackOffPolicy()); $result = $proxy->call(function() { // call external service and return result });