maxbrokman / safe-queue
适用于 Laravel 5 的 Laravel Doctrine 友好的守护进程队列工作器
v0.3.0
2017-02-17 15:50 UTC
Requires
- php: >=5.6
- illuminate/queue: ^5.4.9
- laravel-doctrine/orm: ^1.0
Requires (Dev)
- fabpot/php-cs-fixer: ^1.11
- mockery/mockery: ^0.9.4
- phpunit/phpunit: ^5.3
- satooshi/php-coveralls: ^1.0
This package is not auto-updated.
Last update: 2024-09-14 19:20:10 UTC
README
一个适用于 Laravel Doctrine 的 Laravel 队列工作器
何时使用 SafeQueue
- 您使用 Laravel 5
- 您使用 Laravel Doctrine
- Devops 表示
queue:listen
的 CPU 使用率无法接受 - 您想使用
php artisan queue:work --daemon
而不遇到级联的EntityManager is closed
异常
兼容性
工作原理
SafeQueue 覆盖了 Laravel 功能的一小部分,使队列工作器在 Doctrine 中使用时更安全。它确保在 EntityManager 关闭后抛出异常时工作器退出。为了保险起见,它还在处理每个作业之前清除 EM。
安装
使用 composer 安装
composer require maxbrokman/safe-queue
一旦您有了代码,请将以下内容添加到 app.php
中的服务提供者中
MaxBrokman\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
方法相同。
贡献
欢迎 Pull Request。请将 PR 发送到相关分支(0.1, 0.2, 0.3
),具体取决于您针对哪个 Laravel 版本。
运行测试和样式修复器。
vendor/bin/php-cs-fixer fix
vendor/bin/phpunit
维护
我将此作为我的日常工作的一部分来维护,请在 Github 上提出任何问题