Skip to content
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

Merged
merged 2 commits into from
Sep 26, 2024
Merged

Conversation

morph-dev
Copy link
Contributor

Inspired by AlloyDB, I created DatabaseAsync and DatabaseAsyncRef traits that are async versions of Database and DatabaseRef. They are accompanied by WrapDatabaseAsync, 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.

Copy link
Member

@rakita rakita left a 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;
Copy link
Member

@rakita rakita Sep 26, 2024

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.

@rakita rakita merged commit 411d0ef into bluealloy:main Sep 26, 2024
27 checks passed
@morph-dev morph-dev deleted the async_db branch September 26, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants