-
Notifications
You must be signed in to change notification settings - Fork 593
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
feat: add support for async database #1809
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.
nice! lgtm
fn basic_async( | ||
&mut self, | ||
address: Address, | ||
) -> impl Future<Output = Result<Option<AccountInfo>, Self::Error>> + Send; |
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 not up to date with what is canonical way to express this. I know that async fn
is a possibility but after googling it, it seems it is hard to express Send/Sync/static requirements, and this looks like the best approach.
Inspired by AlloyDB, I created
DatabaseAsync
andDatabaseAsyncRef
traits that are async versions ofDatabase
andDatabaseRef
. They are accompanied byWrapDatabaseAsync
, that handles most of the logic.Portal network already uses almost identical implementation: link.
Note: First time contributing to this repo. Let me know if I'm doing something wrong, have to run some tests, etc.