-
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
Return error from subscription callbacks #799
Conversation
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
…usion Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
…ubscription` Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
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.
nice work
Looks good; the unified sink stuff def feels nicer API wise! My only real blocker is that I don't think we should have |
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
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 looks like a great ergonomics boost, nice! Left some drive-by notes, don't want to comment on the internals yet.
@@ -156,9 +156,10 @@ impl MethodSink { | |||
|
|||
if let Err(err) = self.send_raw(json) { | |||
tracing::warn!("Error sending response {:?}", err); | |||
false |
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 a simple two-variant enum could help understand what the bool
returned from send_error
specifically means
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.
Agree I think it was designed like that to be easy convert to "success/or not" in the middleware but it's unrelated this PR.
Let's tackle it another PR.
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.
LGTM, some minor comments that are optional to fix.
Would be nice to have some abstraction that decouples the state
of the SubscriptionSink
which includes inner method sink
, unsubscribe future
and close_notify
somehow.
I have been thinking that we could just use tokio::sync::mpsc::unbounded_channel
instead futures::mpsc::unbounded_channel
and tokio::sync::Notify
as the sender in tokio has async fn closed
which returns once the receiver
has been dropped which would cancel each subscription on that connection.
That would simplify the SubscriptionSink
slighty :P
Co-authored-by: Niklas Adolfsson <[email protected]>
Co-authored-by: Niklas Adolfsson <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
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.
LGTM, well done!
Subscription callbacks are now returning errors for improved ergonimics.
The jsonrpsee proc-macro renders the provided subscription method with
an additional return type.
While at it, implement
pipe_from_try_stream
on thePendingSubscription
for better ergonomics,which wraps the
pending.accept()
and pipes from the provided stream.Before
After
Closes #734, #735.