yiisoft / queue

Queue extension for Yii 3.0
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
54 stars 28 forks source link

Refactor handlers #182

Closed xepozz closed 4 days ago

xepozz commented 11 months ago
Q A
Is bugfix?
New feature?
Breaks BC? ✔️

Drop support pre-configured handlers, make it compatible with validator/hydrator handlers way

The old way:

  1. Add handler name => handler definition mapping to config/params
  2. Add handler name to the message getHandlerName method

The new way:

  1. Create a class that implements the new MessageHandlerInterface
  2. Add the class name to the message getHandler method

The new way is similar with validator's or hydrator's way.

what-the-diff[bot] commented 11 months ago

PR Summary

Minor changes and adjustments were made throughout the codebase to align with these changes. Please ask if further clarification is needed.

codecov[bot] commented 11 months ago

Codecov Report

Attention: Patch coverage is 45.45455% with 12 lines in your changes missing coverage. Please review.

Project coverage is 83.15%. Comparing base (5339df8) to head (725ef84). Report is 22 commits behind head on master.

Files with missing lines Patch % Lines
src/Worker/Worker.php 36.36% 7 Missing :warning:
config/di.php 0.00% 5 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #182 +/- ## ============================================ - Coverage 83.98% 83.15% -0.84% + Complexity 359 345 -14 ============================================ Files 46 46 Lines 1049 1021 -28 ============================================ - Hits 881 849 -32 - Misses 168 172 +4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features:

xepozz commented 11 months ago

The idea was that handler is not a PHP class string because worker could be implemented in non-PHP.

Already discussed in the internal chat.

There're should be routing outside a message to be able to work with different services across the one queue.

samdark commented 11 months ago

With queue backends such as Redis, there's no external routing.

samdark commented 11 months ago

Discussed internally. It makes sense if we'll introduce "message type decorator" and "message-based handlers" for messages in a separate PR.

viktorprogger commented 4 days ago

Reimplemented in #218, which supports both cases:

With no additional routing.