-
Notifications
You must be signed in to change notification settings - Fork 173
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: support batched subscription notifs #1332
Conversation
{ | ||
let mut nh: Subscription<String> = | ||
client.subscribe("sub", rpc_params![], "unsub").with_default_timeout().await.unwrap().unwrap(); | ||
let response: String = nh.next().with_default_timeout().await.unwrap().unwrap().unwrap(); |
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.
nit: It would be interesting to extend this for 2 subscriptions and 2 (or more) batched notifications and ensure that responses to go appropriate handlers:
let server = WebSocketTestServer::with_hardcoded_subscription(
"127.0.0.1:0".parse().unwrap(),
server_subscription_id_response(Id::Num(0)),
server_batched_subscription(&[("sub1", "batched_notif1"), ("sub2", "resp2")]),
)
let mut sub1 = client.subscribe("sub1", rpc_params![], "unsub");
let mut sub2 = client.subscribe("sub2", rpc_params![], "unsub");
assert_eq!(sub1.next(), "batched_notif1");
assert_eq!(sub2.next(), "resp2");
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 would be a nice extra check yup; right now we can see that the subscription response comes back ok but would be nice to know that eg a few batched subscription responses all end up in the right place :)
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.
If you have a look at the updated test we now emit [notif1, notif2, sub]
and check that it goes to the correct handler (notif=sub, sub_notif=sub)
Sure we could spawn a few more subscriptions to ensure the responses are propagated properly in the Vec
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!
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 :)
* client: support batched subscriptions notifs * address grumbles
Follow-up on #1327