-
Notifications
You must be signed in to change notification settings - Fork 279
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
[suggestion] Fully asynchronous client API #3130
Comments
Comment due to @0x009922 telegram, Feb 9 2023: I think it is not very hard to make the client's API fully Future-based, although it doesn't seem trivial to achieve the most important point (imo): iroha_client should be able to use a generic HTTP-transport instead of having a hard-code dependency such as awc, reqwest etc. The way (as I see) to achieve it is to build the client on top of trait RequestBuilder with an output type Output: Request, where trait Request has fn send(self) -> Pin<Box>. This technique for making an async trait is how async_trait crate works (maybe this crate could be used directly, though). The drawback is:
I think this is not an issue for iroha_client. Even in context of the Explorer which might send a lot of simultaneous requests, it wouldn't be "millions of times a second" - Iroha isn't designed to handle such a load on Torii, is it? By the way, it would be nice if iroha_client provide some implementations for RequestBuilder built on top of awc or whatever, configured by feature flags. |
Comment due to @pesterev, telegram 9 Feb 2023:
Honestly, I didn’t understand this point. awc and reqwest are just a HTTP libraries and provide only a transport layer. I'm concerned about using async because it forces the client to use a specific runtime like tokio. But we can consider using runtime-agnostic libraries and make our library not depend on particular runtime. It will provide a more ergonomic API for all our client library users and won't depend on tokio. |
…parameters Signed-off-by: Aleksandr Petrosyan <a-p-petrosyan@yandex.ru>
…sync and async clients Signed-off-by: Vladimir Pesterev <8786922+pesterev@users.noreply.github.com>
…ient into sync and async parts Signed-off-by: Vladimir Pesterev <8786922+pesterev@users.noreply.github.com>
Feature request
I propose including a version of the API calls which is fully asynchronous and consider further extending the scope of the issue to include generic HTTP transport.
Specifically we want to ensure most implementations don't need to provide an
async_client
implementation (c.f. https://github.com/soramitsu/iroha2-longevity-load-rs/tree/iroha2-dev/src/async_client), and can instead specify their preferred dependencies in feature flags and rely on the provided library.Alternatively, a feasible solution would be to fully generify the API and provide specific implementations as separate crates, e.g.
iroha_client_awc
and/oriroha_client_reqwest
as plugins.Motivation
#3117 shows a method of obtaining cancel-able thread-based transaction submission. However, the API chosen for the initial implementation results in a counter-intuitive API, one which most of our users are likely to ignore.
More importantly, field testing showed that the use cases in which threading would offer advantages are few and far between. Our original assumption about the workflow being mostly thread based turned out to be completely wrong as evidenced by the inclusion of an
async_client
in the blockchain explorer, longevity load script as well as several internal projects.It should also be considered a performance optimisation, given that threading is likely to not fully utilise the threads given the usage pattern.
Who can help?
@pesterev @appetrosyan @0x009922
Meeting minutes for Feb. 10.
Transport agnosticism not as important as assumed, hard-coding
awc
has advantages. Code size impact is minimal.iroha_client
a lightweight API crate,iroha_client_awc
which implements the transport logic to be used in e.g.iroha_client_cli
.iroha_client_cli
to use new crate,longevity-load-rs
to use new crate,blockchain_explorer
to use new crate,async
in trait methods.async
friendly, because most workflows needasync
.The text was updated successfully, but these errors were encountered: