-
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
[feature] #3130: Add type-state-pattern to divide client into sync and async parts #4004
[feature] #3130: Add type-state-pattern to divide client into sync and async parts #4004
Conversation
…ient into sync and async parts Signed-off-by: Vladimir Pesterev <8786922+pesterev@users.noreply.github.com>
bc53519
to
82760e4
Compare
Pull Request Test Coverage Report for Build 6556759437
💛 - Coveralls |
@@ -38,6 +38,7 @@ include/generated/* | |||
peers.list | |||
cmake-build* | |||
result | |||
.obsidian/ |
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.
Wow, what's that?
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.
That is a note-taking app. I use it to render and edit our documentation. Pretty useful.
) -> Result<Self> { | ||
) -> Result<Client<SyncRequestManager<T>>> { |
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 we prefer Self
style
request, | ||
sorting, | ||
request: request.clone(), | ||
sorting: sorting.clone(), |
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 can't see why whis change is needed
pub trait AsyncSendRequest { | ||
type RequestBuilder; | ||
|
||
fn send<'async_trait>( | ||
&'async_trait self, | ||
rb: Self::RequestBuilder, | ||
) -> ::std::pin::Pin< | ||
Box< | ||
dyn ::std::future::Future<Output = Result<http::Response<Vec<u8>>>> | ||
+ Send | ||
+ '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 this an expanstion of async_trait
crate?
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 considered this crate, but it will require users to use this crate as I understand. If we agree with it, then let's use it.
Btw the native async traits have already stabilized and seem can appear in one of the coming releases of Rust.
let assets = test_client | ||
.seek(result) | ||
.collect::<QueryResult<Vec<_>>>() | ||
.expect("Valid"); |
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.
Can you explain how does seek()
work here?
@@ -248,16 +250,41 @@ pub struct ResultSet<T> { | |||
client_cursor: usize, | |||
} | |||
|
|||
impl<T: Clone> Iterator for ResultSet<T> | |||
pub struct SeekResultSet<'a, T, R> |
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 there a particular reason this struct is called Seek
? Also, why does it always uses SyncRequestManager
? Is it more like SyncResultSet
?
Description
This PR adds traits to implement type-state-pattern on
Client
to divide it into sync and async parts.I'm going to open also two pull requests:
iroha_awc
andiroha_hyper
crates implementationsLinked issue
Closes #3130
Benefits
Checklist
CONTRIBUTING.md
iroha_awc
andiroha_hyper
crates