定制 macklus/yii2-simple-queue 二次开发

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

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

macklus/yii2-simple-queue

最新稳定版本:1.0.2

Composer 安装命令:

composer require macklus/yii2-simple-queue

包简介

Yii2 extension to provide SQL based queue worker

README 文档

README

Yii2 extension to provide SQL based queue worker

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist macklus/yii2-simple-queue "*"

or add

"macklus/yii2-simple-queue": "*"

to the require section of your composer.json file.

Configuration

Once the extension is installed, configure it define queue component :

'queue' => [
  'class' => 'macklus\SimpleQueue\SimpleQueue',
  'connection' => 'db',
  'table' => 'simpleQueue',
  'persistent' => true,
  'duplicate_jobs' => false,
],

Optional vars are:

  1. connection: Database connection
  2. table: Name of database table
  3. persistent: If true, no jobs will be delete from database, marked as ENDED as well
  4. duplicate_jobs: Search before insert new job to detect similar one exists

Usage

Once the extension is configured, simply use it to put a job on a queue:

Yii::$app->queue->putInTube($queue, [array_of_vars_of_job]);

Controller

You need a controller to get (and process) all jobs. In example:

<?php

namespace app\commands;

use macklus\SimpleQueue\SimpleQueueController;

class SqController extends SimpleQueueController
{

    const DELAY_PRIORITY = 1000; //Default priority
    const DELAY_TIME = 60; //Default delay time
    const DELAY_MAX = 3;

    public function listenTubes()
    {
        return ['test'];
    }

    public function actionTest($job)
    {
        $jobData = $job->getData();
        // do some stuff
        return self::DELETE;
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2016-03-16