keboola/retry
最新稳定版本:0.5.1
Composer 安装命令:
composer require keboola/retry
包简介
Library for repeatable and retryable operations
README 文档
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 });
统计信息
- 总下载量: 103.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 12
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-11