Skip to content

Comments

feat: add support for async database#1809

Merged
rakita merged 2 commits intobluealloy:mainfrom
morph-dev:async_db
Sep 26, 2024
Merged

feat: add support for async database#1809
rakita merged 2 commits intobluealloy:mainfrom
morph-dev:async_db

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.

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