定制 journey/queue 二次开发

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

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

journey/queue

最新稳定版本:v0.2.2

Composer 安装命令:

composer require journey/queue

包简介

Simple, hierarchical action-test-callback queue written in php

README 文档

README

Queue is a simple, hierarchical action-test-callback queue written in php. The php thread waits however long is necessary in order to complete the entire queue (using Journey\Daemon).

Install

Use composer to install it and load it.

Use

The queue is made up of a registry of QueueItem objects. Each QueueItem has 3 elements:

  • Action
    • __construct(Callable)
    • setAction(Callable)
  • Check
    • unitl(Callable)
    • succeedWhen(Callable)
  • Callback
    • then(Callable)
    • after(Callable)

The queue first performs the action. The queue will then call the check to determine if the action has completed until it receives a truthy value. Finally the queue will call the callback after the check passes.

<?php

include "vendor/autoload.php";

$queue = new Journey\Queue\Queue;

$queue->add(function () {
    // The initial action
})->succeedWhen(function () {
    // A check to see if the action succeeded
})->then(function (Queue $queue) {
    // Do some action
});

$queue->run();

To create hierarchy, simply add another QueueItem in the success callback (then() in the above example). $queue->add(new QueueItem...)

Note: The check methods also support a second parameter (optional) $interval = 0 which defines how frequently each check should wait before being called again (non-blocking). An example of how this would be useful is if you are calling a request-limited API for a status and you only want to check ever 30 seconds rather than 30 times a second

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-12-10