-
Notifications
You must be signed in to change notification settings - Fork 277
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
[refactor] #2144: redesign client's http workflow, expose internal api #2147
Merged
appetrosyan
merged 20 commits into
hyperledger-iroha:iroha2-dev
from
0x009922:task/2144/refactor-client-http
Apr 28, 2022
Merged
[refactor] #2144: redesign client's http workflow, expose internal api #2147
appetrosyan
merged 20 commits into
hyperledger-iroha:iroha2-dev
from
0x009922:task/2144/refactor-client-http
Apr 28, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Co-authored-by: Aleksandr Petrosyan <a-p-petrosyan@yandex.ru> Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
0x009922
added
iroha2-dev
The re-implementation of a BFT hyperledger in RUST
Refactor
Improvement to overall code quality
labels
Apr 25, 2022
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
0x009922
requested review from
s8sato,
appetrosyan,
mversic,
Arjentix,
SamHSmith and
QuentinI
as code owners
April 26, 2022 05:14
s8sato
approved these changes
Apr 26, 2022
Arjentix
approved these changes
Apr 27, 2022
Signed-off-by: 0x009922 <a.marcius26@gmail.com>
mversic
pushed a commit
to mversic/iroha
that referenced
this pull request
May 2, 2022
…xpose internal api (hyperledger-iroha#2147)
appetrosyan
pushed a commit
to appetrosyan/iroha
that referenced
this pull request
May 4, 2022
…xpose internal api (hyperledger-iroha#2147)
appetrosyan
pushed a commit
to appetrosyan/iroha
that referenced
this pull request
May 12, 2022
…xpose internal api (hyperledger-iroha#2147)
appetrosyan
pushed a commit
to appetrosyan/iroha
that referenced
this pull request
May 12, 2022
…xpose internal api (hyperledger-iroha#2147)
appetrosyan
pushed a commit
to appetrosyan/iroha
that referenced
this pull request
May 12, 2022
…xpose internal api (hyperledger-iroha#2147)
appetrosyan
pushed a commit
to appetrosyan/iroha
that referenced
this pull request
May 12, 2022
…xpose internal api (hyperledger-iroha#2147)
appetrosyan
pushed a commit
to appetrosyan/iroha
that referenced
this pull request
May 12, 2022
…xpose internal api (hyperledger-iroha#2147)
appetrosyan
pushed a commit
to appetrosyan/iroha
that referenced
this pull request
May 12, 2022
…xpose internal api (hyperledger-iroha#2147)
appetrosyan
pushed a commit
to appetrosyan/iroha
that referenced
this pull request
May 12, 2022
…xpose internal api (hyperledger-iroha#2147) Signed-off-by: 0x009922 <a.marcius26@gmail.com>
appetrosyan
pushed a commit
to appetrosyan/iroha
that referenced
this pull request
May 12, 2022
…xpose internal api (hyperledger-iroha#2147) Signed-off-by: 0x009922 <a.marcius26@gmail.com>
appetrosyan
pushed a commit
to appetrosyan/iroha
that referenced
this pull request
May 12, 2022
…xpose internal api (hyperledger-iroha#2147) Signed-off-by: 0x009922 <a.marcius26@gmail.com>
mversic
pushed a commit
to mversic/iroha
that referenced
this pull request
May 13, 2022
…xpose internal api (hyperledger-iroha#2147)
mversic
pushed a commit
to mversic/iroha
that referenced
this pull request
May 13, 2022
…xpose internal api (hyperledger-iroha#2147)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
iroha2-dev
The re-implementation of a BFT hyperledger in RUST
Refactor
Improvement to overall code quality
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
Currently client is built on top of blocking synchronous HTTP client, which is not very flexible for different use cases.
To make it more flexible, I've split some of the APIs into 2 parts:
I've moved the part of actual doing the request out of this. By the way, current main function are still using the default http implementation, but these parts are moved out from it.
It is done with a new trait -
RequestBuilder
. I've added several functions to theClient
:prepare_query_request(query, pagination)
, that returns a tuple with a providedRequestBuilder
and a special response handler.prepare_transaction_request(tx)
, same as for queries, but also returns a hash of a transaction.prepare_status_request()
, same as above, but simpler.There are also 3 new structs -
QueryResponseHandler
,TransactionResponseHandler
andStatusResponseHandler
. All of them encapsulates the logic of handling an HTTP-response in a correct way.I haven't touched WebSocket-based logic and some other complex utilities that rely on default HTTP client yet. Anyway it should be refactored as well.
Also I've refactored the http internal module itself.
Issue
Resolves #2144
Benefits
iroha_client
with custom HTTP transport, even async. Only for queries, transactions and status for now.trait RequestBuilder
allows to build requests in an efficient way. It would be less efficient if build it via callbacks or by returning the exact request structure.Possible Drawbacks
Headers
are stillHashMap<String, String>
, which can be optimized in scope ofRequestBuilder
trate.Response
structure from thehttp
crate. It may be unefficient if custom http implementation returns some other response and user has to transform it first. Maybe it is better to replaceResponse
with some trait.Usage Examples or Tests
Existing client methods now uses the same API, but with default HTTP client. See how they now work.