Skip to content

Replace queue commands with queue:consume - #353

Open
samdark wants to merge 5 commits into
masterfrom
issue-350-consume
Open

samdark wants to merge 5 commits into
masterfrom
issue-350-consume

Conversation

@samdark

@samdark samdark commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Replace queue:run, queue:listen, and queue:listen-all with queue:consume so the command name consistently describes message consumption.

  • queue:consume [queueName] listens continuously to one queue, defaulting to yii-queue.
  • queue:consume --once [queueNames...] processes existing messages in one pass and exits. Without names, it uses all configured consumer queues.
  • queue:consume --all [queueNames...] polls the selected queues continuously. Without names, it uses all configured consumer queues.
  • --once takes precedence when combined with --all.

Keep per-queue limits, idle pauses, consumer-only discovery, and graceful signal handling. Reject explicitly supplied options when the selected mode ignores them: --limit requires --once or --all, and --pause requires --all without --once. Help explains queue selection, option scope, and precedence.

Update command registration and usage examples, including cron jobs and process managers.

Fix #350.

Summary by Sourcery

Replace the legacy queue commands with a unified queue:consume command for consistent message consumption across single-queue, one-pass, and multi-queue workflows.

New Features:

  • Introduce a unified queue:consume command supporting single-queue listening, one-pass consumption, and continuous multi-queue polling with clear option precedence and validation.

Enhancements:

  • Remove the separate queue:run, queue:listen, and queue:listen-all commands in favor of the unified consumer interface.
  • Preserve consumer-only queue discovery, per-queue limits, idle pauses, graceful shutdown, and synchronous-mode behavior across the new command.

Documentation:

  • Update queue command documentation, examples, process-manager configurations, and cron guidance to use queue:consume.

Tests:

  • Add coverage for consumption modes, queue selection, option validation, polling behavior, limits, pauses, signal handling, and consumer-role filtering.

Chores:

  • Consolidate command registration and remove obsolete command implementations and references.

@sourcery-ai

sourcery-ai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Replaces queue:run, queue:listen, and queue:listen-all with a single queue:consume command whose default, --once, and --all modes preserve the existing consumption, limiting, discovery, pause, and graceful-shutdown behavior, while updating registration, tests, documentation, and deployment migration examples.

Flow diagram for queue:consume modes

flowchart TD
    Start[queue:consume] --> Mode{Options selected}
    Mode -->|default| Single[Resolve one consumer]
    Single --> Listen[consumer.listen]
    Mode -->|--once| Once[Discover or resolve queues]
    Mode -->|--all| All[Discover or resolve queues]
    Once --> RunOnce[consumer.run per queue]
    RunOnce --> Exit[Exit after one pass]
    All --> RunAll[consumer.run per queue]
    RunAll --> Pause[Pause between idle passes]
    Pause --> RunAll
    RunAll --> Stop[Stop through LoopInterface]
Loading

File-Level Changes

Change Details Files
Consolidate the three queue-processing commands into a single queue:consume command with mode-specific options.
  • Add continuous single-queue consumption as the default mode.
  • Add --once for one-pass processing and --all for continuous multi-queue polling.
  • Reject multiple queue arguments without an explicit multi-queue mode.
  • Retain per-queue limits, idle pauses, consumer-only discovery, output reporting, and loop-based graceful shutdown.
src/Command/ConsumeCommand.php
src/Command/ListenCommand.php
src/Command/RunCommand.php
tests/Unit/Command/ConsumeSingleCommandTest.php
tests/Unit/Command/ConsumeOnceCommandTest.php
tests/Unit/Command/ConsumeAllCommandTest.php
tests/Integration/ConsumeCommandTest.php
tests/Integration/QueueProviderTest.php
tests/Unit/SignalHandlingTest.php
Update command registration and remove the legacy command entry points.
  • Register only queue:consume in the application configuration.
  • Replace manual command-construction examples with ConsumeCommand and its consumer provider/loop dependencies.
  • Document that the old command names are no longer registered.
config/params.php
docs/guide/en/console-commands.md
docs/guide/en/loops.md
CHANGELOG.md
Revise user-facing documentation and operational examples for the unified command.
  • Update README, usage, worker, queue-name, and best-practice examples.
  • Migrate systemd, Supervisor, and cron examples.
  • Add an explicit migration table for previous commands and replacements.
README.md
docs/guide/en/best-practices.md
docs/guide/en/console-commands.md
docs/guide/en/process-managers.md
docs/guide/en/queue-names.md
docs/guide/en/usage.md
docs/guide/en/worker.md
Align loop documentation and regression coverage with queue:consume modes.
  • Update loop and signal-handling references for --all and --once.
  • Test one-pass limits, repeated multi-queue polling, default single-queue listening, invalid argument combinations, consumer-role filtering, and signal restoration.
src/Cli/ScopedLoopInterface.php
tests/Unit/SignalHandlingTest.php
tests/Unit/Command/ConsumeAllCommandTest.php
tests/Unit/Command/ConsumeOnceCommandTest.php
tests/Unit/Command/ConsumeSingleCommandTest.php

Possibly linked issues

  • Rename commands #350: The PR implements the requested renames: queue:run to --once, queue:listen to default queue:consume, and queue:listen-all to --all.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.41%. Comparing base (cbd3661) to head (f979513).

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #353      +/-   ##
============================================
+ Coverage     95.26%   95.41%   +0.15%     
- Complexity      396      400       +4     
============================================
  Files            59       57       -2     
  Lines          1034     1048      +14     
============================================
+ Hits            985     1000      +15     
+ Misses           49       48       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

sourcery-ai[bot]
sourcery-ai Bot previously approved these changes Nov 1, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Linked issues

#350 Rename commands · 3 of 3 met

# Requirement Status Notes
1 Replace queue:run with queue:consume --once. ✅ Met The command handles one pass through the selected queues and exits.
2 Replace queue:listen [queueName] with queue:consume [queueName]. ✅ Met Without --once or --all, the command listens to the selected queue, defaulting to the default queue.
3 Replace queue:listen-all with queue:consume --all. ✅ Met The --all mode repeatedly polls the selected queues, or all configured consumer queues when none are specified.

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@samdark
samdark requested a review from a team November 1, 2026 17:08
Comment thread src/Command/ConsumeCommand.php Resolved
Comment thread src/Command/ConsumeCommand.php Resolved

@KalimeroMK KalimeroMK left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all comments address

@samdark
samdark requested review from viktorprogger and vjik November 2, 2026 19:14
@sourcery-ai
sourcery-ai Bot dismissed their stale review November 2, 2026 19:15

Sourcery withdrew this approval because the latest commits introduced blocking findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename commands

2 participants