-
Notifications
You must be signed in to change notification settings - Fork 224
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
[WIP] Notifications and pubsub transports #10
Conversation
@@ -9,6 +9,30 @@ pub enum Id { | |||
None, | |||
} | |||
|
|||
impl PartialOrd for Id { |
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.
allows use as key in btreemaps. implementation is arbitrary, but totally ordered
use serde::{ser::SerializeMap, Deserialize, Serialize, Serializer}; | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct EthNotification<T = Box<serde_json::value::RawValue>> { |
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.
these are distinct from JSON-PRC notifications (which are ID-less requests)
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.
Superficial review
/// The backend SHOULD shut down when the handle is dropped (as indicated by | ||
/// the shutdown channel). | ||
pub struct ConnectionHandle { |
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.
Should this impl Drop
? Then fn shutdown
just drops self
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.
so this is a bit of a trick with oneshot channels sending ()
. because dropping the sender causes the Receiver to error on future recv
attempts, if you're using the channel to communicate "I've gone away" without any additional info, you never actually need to .send(())
. you can just drop the sender, and have the task owning the receiver treat the error as the communication
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.
we could do this with the receiver half of to_socket
however, doing it that way would always result in the channel being drained into the socket before the task knows it should shut down. Using a separate channel prevents that extra work
} | ||
|
||
/// The reciprocal of [`ConnectionHandle`]. | ||
pub struct ConnectionInterface { |
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.
needs better name
will be superseded |
Motivation
Solution
PR Checklist