-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Backend: remove or replace event subsystem #19812
Comments
In principal, I'm happy with removing lots of things out of the events system, but it seems some notion of asynchronous tasks must still exist. A concrete example is the database sync events I do think the revision system is tasteful in the Ironically, your culprit of Another thing I'm remembering, resyncing schemas used to be syncronous. And then we had to fix a bug where unhiding 15 tables would completely lock up a metabase instance deadlocking on db connections. Just something to remember as we balance these tradeoffs. #15916 |
One of the places |
I think things like saving Revisions should be done synchronously since it adds little overhead when we're already doing DML anyway and it makes that stuff 100x easier to test. I think triggering sync is the only event we'd want to do asynchronously, and in that case it's easy enough to have the event handler that triggers the sync trigger it inside a thread pool or something. I really do like the idea of replacing the unqualified keywords with something namespaced e.g. qualified keywords. I think basically what I want (if we do keep it) it something like the Emacs Lisp hook system. We could actually use the ;; define a new event handler
(derive ::save-database-revision :metabase.models.database/on-created)
(m/defmulti events/dispatch-event ::save-database-revision
[{:keys [database]}]
...) ;; invoke the event handler; executes all matching methods for `events/dispatch-event` sequentially synchronously
(events/dispatch-event :metabase.models.database/on-created {:database db}) That's one way we might do it. IDK, just spitballing |
more discussion in https://metaboat.slack.com/archives/CKZEMT1MJ/p1681410267513569 |
Way back in #956 we added the
metabase.events
subsystem which is a basic pub/sub message queue for different parts of the app. There are a few reasons I think we should remove it:PUT
/POST
API endpoints (if the event handler is doing its own DML stuff)driver/notify-database-updated
gets triggered. I'll wait)I'm not against the idea of decoupling stuff with events and recipients entirely, if it's done tastefully.
NSNotificationCenter
in Cocoa(Touch) or hooks in Emacs Lisp are some examples. I think the main change we'd want to make is to make event dispatch/handling synchronous instead of async. That would fix 90% of my complaints. We'd still have the extra level of indirection tho, and the subsystem would still be used in only a handful of places, which is not enough to justify having it if you ask me.I think we should do one of the following
driver/notify-database-updated
directly inside thePUT /api/database/:id
REST API endpointThe text was updated successfully, but these errors were encountered: