rkr/service-dispatcher
最新稳定版本:0.3.10
Composer 安装命令:
composer require rkr/service-dispatcher
包简介
README 文档
README
Common usage using SQLite
A simple service dispatcher for shell scripts. The intent is to run a php-cli script every minute and let the script decide, what to run at what time...
use Kir\Services\Cmd\Dispatcher\Dispatcher; require __DIR__ . '/vendor/autoload.php'; use Kir\Services\Cmd\Dispatcher\ServiceDispatcherBuilder; $dispatcher = ServiceDispatcherBuilder::withSQLite(__DIR__.'/services.db')->build(); $dispatcher->register('service1', Dispatcher::ONE_HOUR, function () { // Do something throw new Exception(); }); $dispatcher->register('service2', Dispatcher::ONE_HOUR * 3, function () { // Do something }); $dispatcher->run();
The example above show the simplest usage of the service dispatcher. Two services get registered. "Service1" and "Service2". If one service throws an exception, the whole execution stops. Next time, the failed service starts at the end of the queue. If a service was successfully executed, the timeout schedules the service in this case to 1 hour (3600 seconds) in the future.
MySQL-Specific settings:
use Kir\Services\Cmd\Dispatcher\ServiceDispatcherBuilder; require __DIR__ . '/vendor/autoload.php'; /* ... */ $dispatcher = ServiceDispatcherBuilder::withMySQL($pdo) ->useLocking(true) ->setLockPrefix('my-app:') ->build(); $dispatcher->register(/*...*/); /* ... */
统计信息
- 总下载量: 1.6k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-27