定制 keystone/queue 二次开发

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

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

keystone/queue

Composer 安装命令:

composer require keystone/queue

包简介

Create and process background tasks with any queueing service

README 文档

README

Build Status

A PHP library to create and process background tasks with any queueing service.

Supported queue services:

Features:

  • Compatible with any queueing service via provider/publisher interfaces.
  • Middleware to hook into the processing flow (inspired by PSR-15).
  • Route task messages to workers registered as services in PSR-11/Symfony containers.

Middleware:

  • Automatically close timed out Doctrine DBAL connections.
  • Automatically clear the Doctrine ORM managers to free memory.
  • Limit the maximum execution time of the consumer.
  • Limit the maximum number of messages a consumer will process.
  • Limit the maximum amount of memory a consumer is allowed to use.
  • Retry failed tasks using an exponential backoff strategy.
  • Handle signals to terminate the consumer process safely.

Requirements

PHP 7.0 or above is required.

Getting started

Install the library with Composer.

composer require keystone/queue

Create a message class for the task.

use Keystone\Queue\Message;

class HardMessage implements Message
{
    public $name;
    public $count;

    public function __construct(string $name, int $count)
    {
        $this->name = $name;
        $this->count = $count;
    }

    public function getKey(): string
    {
        // The message key is used to determine which queue to publish to.
        return 'hard';
    }
}

Create a worker class capable of processing the message.

class HardWorker
{
    public function process(HardMessage $message)
    {
        // Do some work to process the message.
    }
}

Publish a message within your application.

use Keystone\Queue\Publisher;

$publisher = new Publisher(...);
// The message is serialized when publishing and unserialized when consuming
$publisher->publish(new HardMessage('Billy', 12));

Consume the messages in a long running process.

use Keystone\Queue\Consumer;
use Keystone\Queue\Provider;

$provider = new Provider(...);
$consumer = new Consumer($provider, ...);
// The consumer will poll the queue for new messages and process them.
$consumer->consume();

Credits

License

Released under the MIT Licence. See the bundled LICENSE file for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固