icecave / interlude
模拟同步操作的超时。
0.1.0
2014-11-10 08:16 UTC
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-09-06 11:48:47 UTC
README
Interlude 是一个小的 PHP 库,用于重复执行非阻塞操作,直到成功、达到超时时间或执行了最大尝试次数。
如果您不需要超时功能,您可能想尝试 igorw/retry。
- 通过 Composer 包 icecave/interlude 安装
- 阅读 API 文档
示例
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; }
联系我们
- 关注 @IcecaveStudios 在 Twitter 上
- 访问 Icecave Studios 网站
- 加入
#icecave
在 irc.freenode.net