-
Notifications
You must be signed in to change notification settings - Fork 121
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
AfterCommitAsyncDispatcher does not pass event to custom scheduler #1391
Comments
On the topic:
Aside: is there any reason why you'd monkeypatch |
Actually no 😅. I am passing a project-specific scheduler to the AfterCommitAsyncDispatcher, but I never considered subclassing the dispatcher. I guess I was hoping that the change would be upstreamed "soon" and I could delete my monkey patch. 🙃 |
Just ran into this while trying to introduce jitter (defined on event) into scheduler 🙃 |
Hi folks! I ran into this exact problem today & ended up reimplementing If the change to the scheduler API discussed here ends up in 3.0 that would work for my use-case, but I wonder if it might be possible to ship something before that by making this a purely additive change. I.e., adding something like an The If this is a desirable change I'm happy to submit a PR. Just let me know. |
Every layer from Broker->Scheduler passes a triple of
(subscriber, event, event_record)
, but the very last step hides the event object and only passes the serializ(ed/able) record to custom schedulers:rails_event_store/rails_event_store/lib/rails_event_store/after_commit_async_dispatcher.rb
Lines 9 to 11 in e7ede7d
This is a problem for me because I'd like to run a predicate on the event in my custom scheduler before enqueueing a job. My specific use case involves a fairly frequent event, where only a tiny percentage are actually relevant to a given subscriber.
How I'm working around this
Monkey patch AfterCommitAsyncDispatcher in an initializer:
Suggested patch
The existing API contract is obviously for 2 arguments only. I know arity checking is usually frowned upon, but I feel like it's an acceptable trade-off here:
What do you think? Should this be changed? Would the change be breaking or something that could happen in the 2.x series?
The text was updated successfully, but these errors were encountered: