-
Notifications
You must be signed in to change notification settings - Fork 254
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 everything async #144
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
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.
Awesome, this has been on our wishlist for a while!
Some questions:
- (1) did you consider contributing to the
jsonrpc
crate and implement async functionality there first as well? - (2) I'd like to keep using non-async as a possibility. How would you feel about having a compile feature and duplicating all methods, a sync and async variant? That would also make that we can keep the integration test simpler by keeping it sync.
@@ -22,25 +22,24 @@ pub struct RetryClient { | |||
const INTERVAL: u64 = 1000; | |||
const RETRY_ATTEMPTS: u8 = 10; | |||
|
|||
#[async_trait] |
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.
Is it possible to drop this dependency by just writing the functions more verbose using Future
?
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.
You mean Pin<Box<dyn Future<...> + Send +'_>>
(https://smallcultfollowing.com/babysteps/blog/2019/10/26/async-fn-in-traits-are-hard/)
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 think it may be a little bit more involved, see: https://github.com/dtolnay/async-trait#explanation
Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
|
@stevenroose BDK has implemented something like that (usage example). Maybe we could use that too? |
How does that work? Does it automatically add both async and sync methods on the traits? |
To me it looks like they generate two versions of each function and activate only one depending on a feature flag. It's maybe a bit too much magic, idk. So you have to decide to go full async or not. |
Signed-off-by: Gregory Hill gregorydhill@outlook.com
This still requires some work, but I wanted to open a PR to assess interest - perhaps this belongs in a separate repository.
Uses the reqwest library to perform async http requests and async-trait to support async traits.