Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Messenger] use events consistently in worker#34217
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
/** | ||
* @param RoutableMessageBus $routableBus | ||
*/ | ||
public function __construct($routableBus, ContainerInterface $receiverLocator, LoggerInterface $logger = null, array $receiverNames = [], /* EventDispatcherInterface */ $eventDispatcher = null) | ||
public function __construct($routableBus, ContainerInterface $receiverLocator,EventDispatcherInterface $eventDispatcher,LoggerInterface $logger = null, array $receiverNames = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
EventDispatcher is required to make the limit options reliable.
87db6f8
toffea7d3
Comparesrc/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
private $logger; | ||
private $memoryResolver; | ||
public function __construct(int $memoryLimit, LoggerInterface $logger = null, callable $memoryResolver = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
wouldn't it make sense to make the logger the third argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The memory resolver is mainly for testing and it has been like this before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Great work 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is incredible. It's another very nice cleanup with no downside. Big +1 from me after the minor notes.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Messenger/EventListener/StopWorkerOnSigtermSignalListener.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Messenger/EventListener/StopWorkerOnSigtermSignalListener.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Messenger/EventListener/StopWorkerOnMemoryLimitListener.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
(with minor comments)
9911a6d
to201f159
CompareThank you@Tobion. |
This PR was merged into the 4.4 branch.Discussion----------[Messenger] use events consistently in worker| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | no| New feature? | yes| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets |Fix#32560,#32614,#33843| License | MIT| Doc PR |The worker had the three ways to handle events1. $onHandledCallback in `run(array $options = [], callable $onHandledCallback = null)`2. events dispatched using the event dispatcher3. hardcoded things inside the workerThis PR refactores the messenger worker to only use event dispatching. So instead of a hardcoded `$onHandledCallback` and worker decorators, we use event listeners and we don't need a `WorkerInterface` at all. The behavior of all the options like `--memory-limit` etc remains the same.I introduced two new events- `WorkerStartedEvent`- `WorkerRunningEvent`Together with the existing `WorkerStoppedEvent` it's very symmetrical and solves the referenced issues.Commits-------201f159 [Messenger] use events consistently in worker
This PR was merged into the 4.4 branch.Discussion----------[Messenger] update events for 4.4Documentation forsymfony/symfony#34217Commits-------3374261 [Messenger] update events for 4.4
Uh oh!
There was an error while loading.Please reload this page.
The worker had the three ways to handle events
run(array $options = [], callable $onHandledCallback = null)
This PR refactores the messenger worker to only use event dispatching. So instead of a hardcoded
$onHandledCallback
and worker decorators, we use event listeners and we don't need aWorkerInterface
at all. The behavior of all the options like--memory-limit
etc remains the same.I introduced two new events
WorkerStartedEvent
WorkerRunningEvent
Together with the existing
WorkerStoppedEvent
it's very symmetrical and solves the referenced issues.