-
Notifications
You must be signed in to change notification settings - Fork 177
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
client: Implement notify_on_disconnect
#837
Conversation
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This reverts commit c8ffaa4.
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
/// Completes when the client is disconnected or the client's background task encountered an error. | ||
/// If the client is already disconnected, the future produced by this method will complete immediately. | ||
/// | ||
/// # Cancel safety |
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.
this is really great, we should adopt this idiom IMO to document cancel safety.
most things here are cancel-safe but really great to be explicit.
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.
Agreed! It's so useful to know :)
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
One other thing; can we add a couple of tests for this new function? |
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
}); | ||
Client { | ||
to_back, | ||
request_timeout: self.request_timeout, | ||
error: Mutex::new(ErrorFromBack::Unread(err_rx)), | ||
id_manager: RequestIdManager::new(self.max_concurrent_requests, self.id_kind), | ||
max_log_length: self.max_log_length, | ||
notify: Mutex::new(Some(on_close_rx)), |
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.
no more tokio::sync::Notify
?
doesn't it compile for WASM or what's the reason?
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.
This perhaps?: #837 (comment)
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.
Yep, that's the explanation, mainly to reduce dependencies on tokio 🙏
This PR introduces the client's
notify_on_disconnect
functionality.When called, the method completes when the client is disconnected
or the client's background task encountered an error.
The method is cancel-safe, as the client disconnects or background task
errors are unrecoverable.
Testing Done
client.notify_on_disconnect().await;
Logs
Server
Client
Next
Closes #770.