-
Notifications
You must be signed in to change notification settings - Fork 113
Make EventQueue persistence async
#697
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
base: main
Are you sure you want to change the base?
Conversation
Previously, we'd still use `KVStoreSync` for persistence of our event queue, which also meant calling the sync persistence through our otherwise-async background processor/event handling flow. Here we switch our `EventQueue` persistence to be async, which gets us one step further towards async-everything.
|
👋 Thanks for assigning @joostjager as a reviewer! |
joostjager
left a comment
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.
Straight forward change
|
|
||
| pub(crate) fn add_event(&self, event: Event) -> Result<(), Error> { | ||
| { | ||
| pub(crate) async fn add_event(&self, event: Event) -> Result<(), Error> { |
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.
I was looking at what's left in EventQueue that is sync. Just next_event. Unrelated to this PR, but in every test where that method is used, the test is already async. So it could use the async version?
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.
I was looking at what's left in EventQueue that is sync. Just
next_event. Unrelated to this PR, but in every test where that method is used, the test is already async. So it could use the async version?
But next_event doesn't do anything that would require async operation? It doesn't repersist or anything?
| pub fn event_handled(&self) -> Result<(), Error> { | ||
| self.event_queue.event_handled().map_err(|e| { | ||
| // We use our runtime for the sync variant to ensure `tokio::task::block_in_place` is | ||
| // always called if we'd ever hit this in an outer runtime context. |
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.
Every time I read this, the same question marks pop up. It feels so strange to have regular sync code and worry about an outer runtime. And then we also make it more complicated because our own block_on variant isn't using the internal handle if there is already a context.
Not so straightforward after all. This is blocked as the currently the upstream |
Previously, we'd still use
KVStoreSyncfor persistence of our event queue, which also meant calling the sync persistence through our otherwise-async background processor/event handling flow.Here we switch our
EventQueuepersistence to be async, which gets us one step further towards async-everything.