Skip to content

feat(async-queue): introduce PendingDispatch for fluent job dispatching#7623

Open
huangdijia wants to merge 2 commits intohyperf:3.2from
huangdijia:add-pending-dispatch
Open

feat(async-queue): introduce PendingDispatch for fluent job dispatching#7623
huangdijia wants to merge 2 commits intohyperf:3.2from
huangdijia:add-pending-dispatch

Conversation

@huangdijia
Copy link
Copy Markdown
Member

This commit introduces a new PendingDispatch class that provides a fluent interface for dispatching async queue jobs with enhanced flexibility and composability.

Key changes:

  • Added PendingDispatch class with fluent methods: setMaxAttempts(), onPool(), delay()
  • Integrated Conditionable trait for conditional method chaining (when/unless)
  • Refactored dispatch() function to return PendingDispatch instead of bool
  • Added hyperf/conditionable dependency to composer.json
  • Job dispatch now happens automatically in PendingDispatch destructor
  • Comprehensive test suite with 100% coverage of all features

Breaking change: dispatch() now returns PendingDispatch instead of bool. Users should not assign the return value unless they understand the implications (as noted in the function documentation).

Migration examples:

  • Old: dispatch($job, 60, 3, 'custom');
  • New: dispatch($job)->delay(60)->setMaxAttempts(3)->onPool('custom');

This commit introduces a new PendingDispatch class that provides a fluent interface for dispatching async queue jobs with enhanced flexibility and composability.

Key changes:
- Added PendingDispatch class with fluent methods: setMaxAttempts(), onPool(), delay()
- Integrated Conditionable trait for conditional method chaining (when/unless)
- Refactored dispatch() function to return PendingDispatch instead of bool
- Added hyperf/conditionable dependency to composer.json
- Job dispatch now happens automatically in PendingDispatch destructor
- Comprehensive test suite with 100% coverage of all features

Breaking change: dispatch() now returns PendingDispatch instead of bool. Users should not assign the return value unless they understand the implications (as noted in the function documentation).

Migration examples:
- Old: dispatch($job, 60, 3, 'custom');
- New: dispatch($job)->delay(60)->setMaxAttempts(3)->onPool('custom');
@huangdijia huangdijia added this to the v3.2 milestone Nov 13, 2025
@huangdijia huangdijia marked this pull request as ready for review November 13, 2025 07:12
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.

1 participant