Skip to content

Merge changes into 3.0 branch #530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5349ac9
fix 500
lehaa22 Nov 2, 2023
9e9d465
Merge pull request #501 from lehaa22/fix_500
bizley Nov 2, 2023
ab00a79
Pass TTR StringValue as a string (#502)
timkelty Nov 17, 2023
68bac91
Added PHP 8.3 to CI runners
s1lver Nov 24, 2023
aa4b167
Added support for symfony/process:^7.0 (#508)
aivchen Jan 5, 2024
18398b5
Merge branch '3.0' into php_83
Jan 6, 2024
9f839ba
Fixed UndefinedVariable for psalm 5.18.0
s1lver Jan 6, 2024
6df01d5
Fix #509: Add StatisticsProviderInterface to get statistics from queue
kalmerkaurson Feb 1, 2024
7bfb3d8
update translation in zh-CN (#512)
coderltf Apr 24, 2024
8481457
Update `composer.json` (`allow-plugins` section) (#514)
arogachev Apr 29, 2024
dbc9d4a
release version 2.3.7
arogachev Apr 29, 2024
e1255b0
prepare for next release
arogachev Apr 29, 2024
caf3cb8
Update CHANGELOG.md (#515)
arogachev Apr 29, 2024
46b2eff
Improve wording in package description (#518)
particleflux Oct 8, 2024
9dd5534
Fix #522: Fix SQS driver type error with custom value passed to `queu…
flaviovs Feb 21, 2025
8f4c350
Fix tests (#524)
samdark Feb 21, 2025
d6372d8
Fix #516: Ensure Redis driver messages are consumed at least once
noname007 Mar 11, 2025
48b2cf2
Merge remote-tracking branch 'refs/remotes/upstream/master' into php_83
s1lver May 12, 2025
9858a78
Fixed psalm issues
s1lver May 12, 2025
f547014
Fixed psalm issues
s1lver May 18, 2025
f0264bc
Fixed psalm issues
s1lver May 18, 2025
a941e7c
Fixed psalm issues
s1lver May 18, 2025
d977aa4
Fixed psalm issues
s1lver May 18, 2025
51ff720
Fixed psalm issues
s1lver May 19, 2025
5cfd615
Drop PHP 8.4
s1lver May 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '8.1', '8.2' ]
php: [ '8.2', '8.3' ]
steps:
- name: Checkout.
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '8.1', '8.2' ]
php: [ '8.2', '8.3', '8.4' ]
steps:
- name: Checkout.
uses: actions/checkout@v2
Expand Down
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
Yii2 Queue Extension Change Log
===============================

2.3.7 under development
2.3.8 under development
-----------------------
- Enh #516: Ensure Redis driver messages are consumed at least once (soul11201)
- Bug #522: Fix SQS driver type error with custom value passed to `queue/listen` (flaviovs)

- no changes in this release.

2.3.7 April 29, 2024
--------------------

- Enh #509: Add StatisticsProviderInterface to get statistics from queue (kalmer)


2.3.6 October 03, 2023
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
help: ## Display help information
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

build: ## Build an image from a docker-compose file. Params: {{ v=8.1 }}. Default latest PHP 8.1
build: ## Build an image from a docker-compose file. Params: {{ v=8.2 }}. Default latest PHP 8.2
@cp -n .env.example .env
PHP_VERSION=$(filter-out $@,$(v)) docker-compose up -d --build
PHP_VERSION=$(filter-out $@,$(v)) docker compose up -d --build
make create-sqs-queue
make create-sqs-fifo-queue

test: ## Run tests. Params: {{ v=8.1 }}. Default latest PHP 8.1
test: ## Run tests. Params: {{ v=8.2 }}. Default latest PHP 8.2
make build
PHP_VERSION=$(filter-out $@,$(v)) docker-compose run yii2-queue-php vendor/bin/phpunit --coverage-clover coverage.xml
PHP_VERSION=$(filter-out $@,$(v)) docker compose run yii2-queue-php vendor/bin/phpunit --coverage-clover coverage.xml
make down

down: ## Stop and remove containers, networks
docker-compose down
docker compose down

benchmark: ## Run benchmark. Params: {{ v=8.1 }}. Default latest PHP 8.1
PHP_VERSION=$(filter-out $@,$(v)) docker-compose build --pull yii2-queue-php
PHP_VERSION=$(filter-out $@,$(v)) docker-compose run yii2-queue-php tests/yii benchmark/waiting
benchmark: ## Run benchmark. Params: {{ v=8.2 }}. Default latest PHP 8.2
PHP_VERSION=$(filter-out $@,$(v)) docker compose build --pull yii2-queue-php
PHP_VERSION=$(filter-out $@,$(v)) docker compose run yii2-queue-php tests/yii benchmark/waiting
make down

sh: ## Enter the container with the application
docker exec -it yii2-queue-php sh

static-analyze: ## Run code static analyze. Params: {{ v=8.1 }}. Default latest PHP 8.1
PHP_VERSION=$(filter-out $@,$(v)) docker-compose build --pull yii2-queue-php
PHP_VERSION=$(filter-out $@,$(v)) docker-compose run yii2-queue-php vendor/bin/psalm --config=psalm.xml --shepherd --stats --php-version=$(v)
static-analyze: ## Run code static analyze. Params: {{ v=8.2 }}. Default latest PHP 8.2
PHP_VERSION=$(filter-out $@,$(v)) docker compose build --pull yii2-queue-php
PHP_VERSION=$(filter-out $@,$(v)) docker compose run yii2-queue-php vendor/bin/psalm --config=psalm.xml --shepherd --stats --php-version=$(v)
make down

clean:
docker-compose down
docker compose down
rm -rf tests/runtime/*
rm -f .php_cs.cache
rm -rf composer.lock
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md).

## Requirements

- PHP 8.1 or higher.
- PHP 8.2 or higher.

Installation
------------
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yiisoft/yii2-queue",
"description": "Yii2 Queue Extension which supported DB, Redis, RabbitMQ, Beanstalk, SQS and Gearman",
"description": "Yii2 Queue Extension which supports queues based on DB, Redis, RabbitMQ, Beanstalk, SQS, and Gearman",
"type": "yii2-extension",
"keywords": ["yii", "queue", "async", "gii", "db", "redis", "rabbitmq", "beanstalk", "gearman", "sqs"],
"license": "BSD-3-Clause",
Expand All @@ -16,9 +16,9 @@
"docs": "https://github.com/yiisoft/yii2-queue/blob/master/docs/guide"
},
"require": {
"php": ">=8.1",
"yiisoft/yii2": "~2.0.14",
"symfony/process": "^6.3",
"php": ">=8.2",
"yiisoft/yii2": "~2.0.50",
"symfony/process": "^7.0",
"laravel/serializable-closure": "^v1.3.0"
},
"require-dev": {
Expand All @@ -33,7 +33,7 @@
"enqueue/stomp": "^0.10.0",
"pda/pheanstalk": "^5.0.0",
"aws/aws-sdk-php": "3.285.0",
"vimeo/psalm": "^5.10.0"
"vimeo/psalm": "^6.0.0"
},
"suggest": {
"ext-pcntl": "Need for process signals.",
Expand Down
23 changes: 14 additions & 9 deletions docs/guide-zh-CN/retryable.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
错误与重复执行
=========================

在作业处理期间可以抛出异常。 当请求的服务和外部资源不可用时,由于代码编写的比较糟糕而导致的内部错误
在第二种情况下,可以在一段时间后重新尝试这个作业
作业的执行可能会失败。这可能是由于内部错误造成的,这些错误是由编写不当的代码导致的,应该首先修复。但是,它们也可能由于外部问题(例如服务或资源不可用)而失败。这可能会导致异常或超时
在后一种情况下,最好能够在一段时间后重试作业。有几种方法可以做到这一点

有几种方法可以做到这一点
>注意:下面描述的 ttr 功能需要安装 [PHP Process Control (pcntl)](https://www.php.net/manual/en/book.pcntl.php) 扩展,并且 worker 命令必须使用 --isolate 选项(默认启用)

重试选项
-------------
Expand All @@ -21,7 +21,12 @@
],
```

`ttr` 选项设置了在队列中保留工作的时间。如果一份作业在这段时间没有执行,它将返回队列进行重试。
`ttr` 选项设置了作业必须成功完成的秒数。因此,可能会发生两件事来使工作失败:
1. 作业在`ttr`结束之前发生异常
2. 完成作业所需的时间将比 ttr 长(超时),工作线程停止作业执行

在这两种情况下,作业都将发送回队列进行重试。但请注意,在第一种情况下,即使作业在运行后立即停止,也不会立即重试,要等到`ttr`"用完"。也就是说,在将作业发送回队列之前,必须经过剩余的 ttr 秒数。

`attempts` 选项设置了最大的尝试次数。如果尝试已经结束,作业作还没有完成,它将从队列中移除。

这种将全局设置队列中的所有作业,如果您需要为多个作业进行不同的设置可以使用,
Expand All @@ -30,7 +35,7 @@
重试作业接口
----------------------

Separate control of retry is implemented by `RetryableJobInterface` 接口。 示例:
为了更好地控制重试逻辑,作业可以实现 `RetryableJobInterface` 接口。 示例:

```php
class SomeJob extends BaseObject implements RetryableJobInterface
Expand Down Expand Up @@ -85,14 +90,14 @@ Yii::$app->queue->on(Queue::EVENT_AFTER_ERROR, function (ExecEvent $event) {
限制
------------

完全支持 [Beanstalk], [DB], [File] 和 [Redis] 驱动程序的重试工具
[Sync] 驱动不会重试失败的工作 [Gearman] 不支持重试
[RabbitMQ] 基本版支持,但重试编号无法得到
[Beanstalk], [DB], [File] 和 [Redis] 驱动程序实现了对可重试作业的完全支持
[Sync] 驱动不会重试失败的作业 [Gearman] 不支持重试作业
[RabbitMQ] 只有其基本的可重试支持,其中无法设置尝试次数

[Beanstalk]: driver-beanstalk.md
[DB]: driver-db.md
[File]: driver-file.md
[Redis]: driver-redis.md
[Sync]: driver-sync.md
[Gearman]: driver-gearman.md
[RabbitMQ]: driver-amqp.md
[RabbitMQ]: driver-amqp.md
14 changes: 14 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,19 @@
</stubs>
<issueHandlers>
<MixedAssignment errorLevel="suppress"/>
<PropertyNotSetInConstructor errorLevel="suppress" />
<RedundantPropertyInitializationCheck errorLevel="suppress" />
<RiskyTruthyFalsyComparison errorLevel="suppress" />
<MissingOverrideAttribute errorLevel="suppress" />
<!-- for BC -->
<ClassMustBeFinal errorLevel="suppress"/>
<FalsableReturnStatement errorLevel="suppress"/>
<PossiblyFalseArgument errorLevel="suppress"/>
<PossiblyFalsePropertyAssignmentValue errorLevel="suppress"/>
<PossiblyFalseIterator errorLevel="suppress"/>
<InvalidFalsableReturnType errorLevel="suppress"/>
<InvalidOperand errorLevel="suppress"/>
<MixedArgument errorLevel="suppress"/>
<MissingClassConstType errorLevel="suppress"/>
</issueHandlers>
</psalm>
2 changes: 1 addition & 1 deletion src/InvalidJobException.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
private readonly string $serialized,
string $message = '',
int $code = 0,
Throwable $previous = null
?Throwable $previous = null
)
{
parent::__construct($message, $code, $previous);
Expand Down
2 changes: 1 addition & 1 deletion src/JobEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ abstract class JobEvent extends Event
/**
* @var Queue
* @inheritdoc
* @psalm-suppress PropertyNotSetInConstructor, NonInvariantDocblockPropertyType
* @psalm-suppress NonInvariantDocblockPropertyType
*/
public $sender;
/**
Expand Down
68 changes: 68 additions & 0 deletions src/cli/InfoAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

declare(strict_types=1);

/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license https://www.yiiframework.com/license/
*/

namespace yii\queue\cli;

use yii\base\NotSupportedException;
use yii\console\Controller;
use yii\helpers\Console;
use yii\queue\interfaces\DelayedCountInterface;
use yii\queue\interfaces\DoneCountInterface;
use yii\queue\interfaces\ReservedCountInterface;
use yii\queue\interfaces\StatisticsProviderInterface;
use yii\queue\interfaces\WaitingCountInterface;

/**
* Info about queue status.
*
* @author Kalmer Kaurson <kalmerkaurson@gmail.com>
*
* @property Controller $controller
*/
class InfoAction extends Action
{
/**
* @var Queue
*/
public Queue $queue;

/**
* Info about queue status.
*/
public function run(): void
{
if (!($this->queue instanceof StatisticsProviderInterface)) {
throw new NotSupportedException('Queue does not support ' . StatisticsProviderInterface::class);
}

$this->controller->stdout('Jobs' . PHP_EOL, Console::FG_GREEN);
$statisticsProvider = $this->queue->getStatisticsProvider();

if ($statisticsProvider instanceof WaitingCountInterface) {
$this->controller->stdout('- waiting: ', Console::FG_YELLOW);
$this->controller->stdout($statisticsProvider->getWaitingCount() . PHP_EOL);
}

if ($statisticsProvider instanceof DelayedCountInterface) {
$this->controller->stdout('- delayed: ', Console::FG_YELLOW);
$this->controller->stdout($statisticsProvider->getDelayedCount() . PHP_EOL);
}

if ($statisticsProvider instanceof ReservedCountInterface) {
$this->controller->stdout('- reserved: ', Console::FG_YELLOW);
$this->controller->stdout($statisticsProvider->getReservedCount() . PHP_EOL);
}

if ($statisticsProvider instanceof DoneCountInterface) {
$this->controller->stdout('- done: ', Console::FG_YELLOW);
$this->controller->stdout($statisticsProvider->getDoneCount() . PHP_EOL);
}
}
}
1 change: 0 additions & 1 deletion src/cli/VerboseBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class VerboseBehavior extends Behavior
public $owner;
/**
* @var Controller
* @psalm-suppress PropertyNotSetInConstructor
*/
public Controller $command;

Expand Down
3 changes: 1 addition & 2 deletions src/cli/WorkerEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ class WorkerEvent extends Event
/**
* @var Queue
* @inheritdoc
* @psalm-suppress PropertyNotSetInConstructor, NonInvariantDocblockPropertyType
* @psalm-suppress NonInvariantDocblockPropertyType
*/
public $sender;
/**
* @var LoopInterface
* @psalm-suppress PropertyNotSetInConstructor
*/
public LoopInterface $loop;
/**
Expand Down
2 changes: 1 addition & 1 deletion src/closure/Behavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Behavior extends \yii\base\Behavior
{
/**
* @var Queue
* @psalm-suppress PropertyNotSetInConstructor, NonInvariantDocblockPropertyType
* @psalm-suppress NonInvariantDocblockPropertyType
*/
public $owner;

Expand Down
1 change: 0 additions & 1 deletion src/debug/Panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* Debug Panel.
*
* @author Roman Zhuravlev <zhuravljov@gmail.com>
* @psalm-suppress PropertyNotSetInConstructor
*/
class Panel extends BasePanel implements ViewContextInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/amqp_interop/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Command extends CliCommand
{
/**
* @var Queue
* @psalm-suppress PropertyNotSetInConstructor, NonInvariantDocblockPropertyType
* @psalm-suppress NonInvariantDocblockPropertyType
*/
public CliQueue $queue;

Expand Down
2 changes: 1 addition & 1 deletion src/drivers/beanstalk/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Command extends CliCommand
{
/**
* @var Queue
* @psalm-suppress PropertyNotSetInConstructor, NonInvariantPropertyType, NonInvariantDocblockPropertyType
* @psalm-suppress NonInvariantPropertyType, NonInvariantDocblockPropertyType
*/
public CliQueue $queue;
/**
Expand Down
3 changes: 2 additions & 1 deletion src/drivers/db/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use yii\console\Exception;
use yii\queue\cli\Command as CliCommand;
use yii\queue\cli\Queue as CliQueue;
use yii\queue\cli\InfoAction;

/**
* Manages application db-queue.
Expand All @@ -23,7 +24,7 @@ class Command extends CliCommand
{
/**
* @var Queue
* @psalm-suppress PropertyNotSetInConstructor, NonInvariantDocblockPropertyType
* @psalm-suppress NonInvariantDocblockPropertyType
*/
public CliQueue $queue;
/**
Expand Down
4 changes: 3 additions & 1 deletion src/drivers/db/InfoAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
/**
* Info about queue status.
*
* @deprecated Will be removed in 3.0. Use yii\queue\cli\InfoAction instead.
*
* @author Roman Zhuravlev <zhuravljov@gmail.com>
*/
class InfoAction extends Action
{
/**
* @var Queue
* @psalm-suppress PropertyNotSetInConstructor, NonInvariantDocblockPropertyType
* @psalm-suppress NonInvariantDocblockPropertyType
*/
public CliQueue $queue;

Expand Down
Loading