定制 bearframework/tasks-addon 二次开发

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

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

bearframework/tasks-addon

最新稳定版本:v1.6.0

Composer 安装命令:

composer require bearframework/tasks-addon

包简介

Tasks addon for Bear Framework

README 文档

README

A lightweight task scheduling and execution addon for Bear Framework. It lets you register task handlers, enqueue work items with scheduling and priority options, and process them via a runnable worker.

Snippets

Define task (register handler)

$app->tasks
    ->define('definition-id', function ($value): void {
        // code
    })

Add task

$app->tasks
    ->add('definition-id', 'example-value', [
        'id' => 'task-id', // optional
        'listID' => '', // empty value for the default list
        'startTime' => time() + 120, // start in 2 minutes
        'priority' => 3, // 1 - lowest, 5 - highest
        'ignoreIfExists' => true, // will check the id only
    ]);

Run tasks

$app->tasks
    ->addEventListener('runTask', function (\BearFramework\Tasks\RunTaskEventDetails $eventDetails) use ($app) {
        $app->logs->log('run-task', $eventDetails->definitionID);
    })
    ->run([
        'listID' => '',
        'maxExecutionTime' => 30
    ]);

Contributing

Contributions and bug reports are welcome. Open issues or submit pull requests to the repository.

License

This addon is free to use under the MIT license. See the LICENSE file for details.

统计信息

  • 总下载量: 2.03k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-07