lwk / safe-queue
适用于 Laravel Doctrine 的 Laravel 队列守护进程
v2.0.0
2024-08-03 09:42 UTC
Requires
- php: ^8.1|^8.2|^8.3
- illuminate/queue: ^10.0|^11.0
- laravel-doctrine/orm: ^2.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.40
- mockery/mockery: ^1.6
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2024-09-03 09:50:34 UTC
README
一个适用于 Laravel Doctrine 的 Laravel 队列工作进程
何时使用 SafeQueue
- 您使用 Laravel 6 或更高版本
- 您使用 Laravel Doctrine
- Devops 表示
queue:listen
的 CPU 使用率无法接受 - 您想在没有任何级联
EntityManager is closed
异常的情况下运行php artisan queue:work --daemon
兼容性
工作原理
SafeQueue 通过覆盖 Laravel 的一小部分功能来使队列工作进程与 Doctrine 一起使用更安全。它确保在 EntityManager 关闭后抛出异常时工作进程会退出。为了保险起见,它还在处理每个任务之前清除 EM。
安装
使用 composer 安装
composer require digbang/safe-queue
一旦您有了代码,请将以下内容添加到 app.php
中的服务提供者:
Digbang\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
方法相同。