-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[10.x] Add queue job debouncing #50347
Conversation
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 approach doesn't work because it's possible the cache key is added but then the dispatch fails. This is why there is no such thing as exactly once delivery. Either we have at most once or at least once. Laravel always chooses at least once, but this deviates from that meaning that in some cases, jobs never get dispatched. I don't think this belongs in the core, but you could make a package for this.
so if this is remedied, you would have no issues with it?
|
Please mark this as ready for review once you're done. |
The way I understand it the logic path of the failed dispatch is the following:
This means we can register events against the |
@nandi95 please just work out something you want to propose, make the tests pass and mark this PR as ready for review. Thanks! |
Please send this to 11.x instead, thanks. |
Note
This is a work-in-progress, but I would like some feedback before spending any more time on this.
I have come across the need for such logic multiple times now, so I'm attempting to add this in a backward compatible way. The goal is to make it work with the existing infrastructure so the user doesn't have to add an extra trait or interface to the jobs, they can just start dispatching with debouncing working.
Why add this?
Sometimes a job might do some heavy computation or talk to an external api; things that the developer might decide is a waste of resources and should only be executed every so often. In this case, a debouncing pattern should be available to prevent spamming the logic path.
Example use-cases:
Questions/Considerations to discuss:
Previous discussion: #43946