zmaglica/safe-queue

Laravel Doctrine 亲友好用的 Laravel 5 队列守护进程

3.0.1 2019-09-30 11:50 UTC

README

Latest Version on Packagist Software License

一个适用于 Laravel Doctrine 的安全 Laravel 队列工作进程

来自 https://github.com/maxbrokman/SafeQueue 的分支

何时使用 SafeQueue

  • 您使用 Laravel 5
  • 您使用 Laravel Doctrine
  • Devops 表示 queue:listen 的 CPU 使用率不可接受
  • 您想在执行 php artisan queue:work --daemon 而不遇到级联的 EntityManager is closed 异常

兼容性

工作原理

SafeQueue 覆盖了 Laravel 功能的一小部分,以确保队列工作进程在使用 Doctrine 时安全。它确保在实体管理器关闭后,工作进程会退出。为了安全起见,它还在处理每个作业之前清除 EM。

安装

使用 composer 安装

composer require zmaglica/safe-queue

一旦您有了代码,请将以下内容添加到 app.php 中的服务提供者:

Zmaglica\SafeQueue\DoctrineQueueProvider::class
Lumen

创建配置文件 config/safequeue.php 并加载: $app->configure('safequeue');

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Worker Command Name
    |--------------------------------------------------------------------------
    |
    | Configure the signature / name of the Work Command here. The default
    | is to rename the command to 'doctrine:queue:work', however you can
    | rename it to whatever you want by changing this value.
    |
    | To override the Laravel 'queue:work' command name just set this
    | to a false value or 'queue:work'.
    |
    */
    'command_name' => 'doctrine:queue:work',

];

用法

php artisan doctrine:queue:work  connection --daemon --sleep=3 --tries=3 ...

所有选项与 Laravel 自身的 queue:work 方法相同。

贡献

欢迎 PR。请将 PR 发送到相关分支(0.1, 0.2, 0.3),具体取决于您要针对哪个 Laravel 版本。

运行测试和风格修复器。

vendor/bin/php-cs-fixer fix
vendor/bin/phpunit

维护

我在日常工作的一部分中维护此项目,请在 Github 上打开任何问题。