定制 mirocow/yii2-queue 二次开发

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

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

mirocow/yii2-queue

Composer 安装命令:

composer require mirocow/yii2-queue

包简介

Yii 2.0 Non blocking queue extension.

关键字:

README 文档

README

Latest Stable Version Latest Unstable Version Total Downloads License Join the chat at https://gitter.im/Mirocow/yii2-queue FOSSA Status Maintainability

----------------------- YII2-QUEUE -----------------------------
Yii2-queue version: 0.0.3          PHP version:7.0.27-0+deb9u1
Process ID: 6930
Channels: 1
Workers: 4
Default queue name: default-queue
----------------------------------------------------------------
Press Ctrl+C to stop. Start success.
Child process starting with PID 6880 ...
Child process 6880 are working...
Child 6880 done
Child process starting with PID 6882 ...
Child process 6882 are working...
Run worker [web] with action [ProductCreate] from common\models\essence\Product
...
Install:

php composer.phar require mirocow/yii2-queue "^1.0.0"

Config:
'controllerMap' => [
    'queue' => [
        'class' => 'mirocow\queue\controllers\QueueController',
    ],
],

'components' => [

    'queue' => [
        'class' => 'mirocow\queue\components\QueueComponent',
        'queueName' => 'default-queue',
        'workers' => [
            'notification' => [
                'class' => 'mirocow\queue\components\WorkerComponent',
                'action' => [
                    'class' => 'mirocow\queue\controllers\NotificationController',
                ]
            ],
            ...
        ],
        'channels' => [
            'default' => [
                'class' => 'mirocow\queue\components\ChannelComponent',
                    'driver' => [
                        'class' => 'mirocow\queue\drivers\MysqlConnection',
                        'connection' => 'db',
                    ]
                ]
            ],
            ...
        ]
    ]
]

Before use apply migrations for using Mysql driver:

./yii migrate/up --migrationPath=@vendor/mirocow/yii2-queue/migrations

Usage:

Worker class:

namespace \console\controllers;

class NotificationController extends Controller
{
    public function actionSayHello($say)
    {
        \Yii::info($say);
    }
}

Push message to queue:

Yii::$app->queue->getChannel('default')->push(
    new MessageModel([
        'worker' => 'notification',
        'method' => 'actionSayHello',
        'arguments' => [
            'say' => 'hello!'
        ]
    ])
);

Run queue worker daemon (console app):

$ php ./yii queue/run --pid-file=/tmp/queue.pid
Test:
$ ./vendor/bin/codecept -c vendor/mirocow/yii2-queue run unit

XDebug could not open the remote debug file '/var/log/php7-fpm/php-fpm-xdebug-remote'.
Codeception PHP Testing Framework v2.4.3
Powered by PHPUnit 6.5.9 by Sebastian Bergmann and contributors.

Unit Tests (6) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- ActionsTest: Run job as class methodWorker process starting with PID 23383 ...
Process 23383 are working...
Process 23383 finished
✔ ActionsTest: Run job as class method (0.15s)
- ActionsTest: Run job class static methodWorker process starting with PID 23383 ...
Process 23383 are working...
Process 23383 finished
✔ ActionsTest: Run job class static method (0.04s)
- ActionsTest: Run job as action of controllerWorker process starting with PID 23383 ...
Process 23383 are working...
Process 23383 finished
✔ ActionsTest: Run job as action of controller (0.05s)
- ActionsTest: Run job as static methodWorker process starting with PID 23383 ...
Process 23383 are working...
Process 23383 finished
✔ ActionsTest: Run job as static method (0.04s)
- FileTest: Job as class methodWorker process starting with PID 23383 ...
Process 23383 are working...
Process 23383 finished
✔ FileTest: Job as class method (0.03s)
- RedisTest: Job as classWorker process starting with PID 23383 ...
Process 23383 are working...
Process 23383 finished
✔ RedisTest: Job as class (0.03s)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Time: 1.34 seconds, Memory: 16.00MB

License

FOSSA Status

统计信息

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

GitHub 信息

  • Stars: 11
  • Watchers: 2
  • Forks: 33
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2018-07-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固