Skip to content

[Messenger] Separate WorkerRunningEvent into WorkerBusyEvent and WorkerIdleEvent #47573

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 7.4
Choose a base branch
from

Conversation

Jeroeny
Copy link
Contributor

@Jeroeny Jeroeny commented Sep 14, 2022

Q A
Branch? 7.1
Bug fix? no
New feature? yes
Deprecations? maybe
License MIT

A common usecase for WorkerRunning listeners seems to be that they perform logic based on $event->isWorkerIdle(). E.g. sometimes services only need to reset if a message has been processed. Or non-critical logic needs to happen when the worker is not busy, to keep the processing performant (like keeping a cache warm or sending buffered metrics).
Right now each of those listeners need to be called, upon which they check themselves if the worker is busy. To increase performance, the WorkerRunning event can be split into WorkerBusyEvent and WorkerIdleEvent. This way listeners can be explicit about when they want to act. Since these events are emitted in a loop, this could make a difference.

There doesn't seem to be a way to deprecate an event, so I think the WorkerRunning event remains.
Though WorkerRunning::isWorkerIdle() could be deprecated to stimulate the usage of the new events.

@xabbuh xabbuh modified the milestones: 7.1, 7.2 May 15, 2024
@fabpot fabpot modified the milestones: 7.2, 7.3 Nov 20, 2024
@fabpot fabpot modified the milestones: 7.3, 7.4 May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants