定制 rkr/service-dispatcher 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rkr/service-dispatcher

最新稳定版本:0.3.10

Composer 安装命令:

composer require rkr/service-dispatcher

包简介

README 文档

README

Build Status Scrutinizer Code Quality Latest Stable Version License

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

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-27