cryptoman3 / safe-queue
A Laravel Doctrine 优化的守护进程队列工作进程,适用于 Laravel
v3.1
2024-08-09 17:48 UTC
Requires
- php: ^7.4 || ^8.2 || ^8.3
- illuminate/queue: ^8.0 || ^9.0 || ^10.0 || ^11.0
- laravel-doctrine/orm: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.6
- mockery/mockery: ^1.5
- phpunit/phpunit: ^8.5 || ^9.5 || ^11.0
This package is not auto-updated.
Last update: 2024-09-20 18:28:52 UTC
README
一个适用于 Laravel Doctrine 的 Laravel 队列工作进程,安全可靠
何时使用 SafeQueue
- 您使用 Laravel 6 或更高版本
- 您使用 Laravel Doctrine
- Devops 表示
queue:listen
的 CPU 使用率不可接受 - 您想使用
php artisan queue:work --daemon
而不会遇到级联的EntityManager is closed
异常
兼容性
工作原理
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
方法相同。