connectholland/tactician-scheduler-plugin
最新稳定版本:1.1.1
Composer 安装命令:
composer require connectholland/tactician-scheduler-plugin
包简介
Tactician plugin that allows scheduling a command to be executed at a specific time in the future
README 文档
README
Tactician plugin that allows scheduling a command to be executed at a specific time in the future
Concept
This plugin allows you to create ScheduledCommands that will be executed at a specific time in the future.
Usage
Make sure you put the SchedulerMiddleware in your CommandBus middleware chain:
// create your other middleware $middleware[] = new SchedulerMiddleware(new FileBasedScheduler($pathWhereTheSchedulerMayKeepItsFiles) ); // create your other middleware $commandbus = new CommandBus($middleware);
Let the command you want to schedule extend from AbstractScheduledCommand or implement the ScheduledCommandInterface. Create it and set a execution time:
class SayHappyNewYear extends AbstractScheduledCommand { private $message; public function __construct($message) { $this->message = $message; } public function getMessage() { return $this->message; } } $myScheduledCommand = new SayHappyNewYear('Happy New Year'); $myScheduledCommand->setTimestamp(strtotime('2016-01-01 0:00:00') ); $myCommandBus->handle($myScheduledCommand);
Create a bootstrap file that builds your Commandbus and cron the schedule execution command, for example bootstrap.php
// setup any environment you need // create your other middleware $middleware[] = new SchedulerMiddleware(new FileBasedScheduler($pathWhereTheSchedulerMayKeepItsFiles) ); // create your other middleware $commandbus = new CommandBus($middleware); return $commandbus;
Cron the scheduler at any interval you like (the more it runs, the better you can time your commands), example for once a minute
* * * * * www-data vendor/bin/scheduler scheduler:execute bootstrap.php
Or you can use the daemon command that ships with the package, to schedule an iteration every 10 seconds use:
vendor/bin/scheduler scheduler:daemon bootstrap.php 10
To make it stop after a minute use:
vendor/bin/scheduler scheduler:daemon bootstrap.php 10 6
connectholland/tactician-scheduler-plugin 适用场景与选型建议
connectholland/tactician-scheduler-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.52k 次下载、GitHub Stars 达 21, 最近一次更新时间为 2015 年 08 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 connectholland/tactician-scheduler-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 connectholland/tactician-scheduler-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.52k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 21
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-18