Handler callback cannot say "consumed" and "stop" separately
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- php
調査の方向性
Start with the runExisting() and subscribe() callback contracts and trace how adapters use their boolean result; the issue names queue-redis Adapter.php:36 and queue-amqp ExistingMessagesConsumer.php:45 as examples. Compare the graceful shutdown path with run($max) counting, then evaluate how a revised result can preserve both consumption and stop status across the shared contract. Done when handled messages are acknowledged and counted even as the loop stops, while refused messages remain unconsumed.
索引モデルが issue の本文から書いたものです。
説明
The handler callback passed to runExisting() and subscribe() returns one bool, and it is asked to carry two independent facts: whether the message was consumed, and whether the adapter should keep delivering.
They disagree on graceful shutdown. QueueConsumer::handle() processes the message and then returns $this->loop->canContinue():
private function handle(MessageInterface $message): bool
{
$this->worker->process($message, $this->queueName);
return $this->loop->canContinue();
}
So when SignalLoop sees SIGTERM, the callback returns false for a message that was handled to completion. Every adapter then keeps it:
queue-redisskips thedelete()(Adapter.php:36)queue-amqpsendsbasic_nack($tag, false, true)(ExistingMessagesConsumer.php:45)
The message is processed again on the next run. For a non-idempotent handler — a charge, an email, a webhook — that is a duplicate on every restart, deploy or scale-down, which is when SIGTERM arrives.
run($max) has the same shape: it reports $count messages processed, but the message handled just before the loop stops is not counted, because the early return skips the increment.
Both fall out of the single return value, so they cannot be fixed in a consumer or in an adapter alone. Some options:
- the callback returns an enum (
Consumed,ConsumedAndStop,NotConsumed) instead of abool, - or the adapter asks separately, e.g. the callback stays "was it consumed" and the loop is checked by the adapter through a second callback or a
LoopInterfaceit already holds.
Raised out of #340, which fixes a related case — a message refused before being handled — without touching this one.
- 主要言語
- PHP
- スター
- 61
- フォーク
- 31
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
yiisoft/queue のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
難易度 4/5 1〜2日 初心者へのやさしさ 47/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 54/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
Automattic/blocks-engine#2866 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
backend gamification P0
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
semanadeinformatica/website#461 ·
-
HttpRequestTrait fatals on WordPress 7.2: $blocked_http_requests clashes with WP_UnitTestCase_Baseオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
area: docs eco: php good first issue help wanted lane: free-agent roadmap size: XS type: docs
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
arminazimi/evergreen#453 ·
メンテナーはふだん 1 日以内に返信