-
Notifications
You must be signed in to change notification settings - Fork 114
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
Make EventQueue persistence async
#697
Conversation
|
👋 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?
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.
Shouldn't we set the example and use the async api of eventqueue?
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.
Ah maybe the naming isn't optimally clear. next_event_async waits, and next_event does not?
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.
The former returns a future, the second one could be named try_next_event.
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.
Yes that would be an improvement indeed.
| 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 |
Recently, `rust-lightning` broke the (async) API of the `TestStore`, making it ~impossible to use in regular tests. Here, we un-DRY our `TestStore` implementation and simply copy over the previous `TestStore` version, now named `InMemoryStore` to discern the objects. We also switch all feasible instances over to use `InMemoryStore` rather than LDK's `test_utils::TestStore`.
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.
3e8464e to
4c72541
Compare
|
Now fixed the CI failure by introducing |
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.