-
Notifications
You must be signed in to change notification settings - Fork 18
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
Refactoring subscription API #108
Conversation
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
@@ -213,7 +219,8 @@ mod test { | |||
let packet = ReceivedPacket::from_buffer(&serialized_suback).unwrap(); | |||
match packet { | |||
ReceivedPacket::SubAck(sub_ack) => { | |||
assert_eq!(sub_ack.code, ReasonCode::GrantedQos2); | |||
assert_eq!(sub_ack.codes.len(), 1); |
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 in general we should never panic on invalid messages. Just log/signal an error and continue.
If we can't skip through them without loosing packet sync, we should close the connection.
Panicing sounds decidedly wrong. But this is a general comment about all the code, not just this location here.
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 specifically a unit test, so we want things to panic on failure. However, I agree with you. I do not believe we panic internally in the library anywhere (or it would be a bug if we did).
It's an interesting point that maybe the software should handle all errors by restting the client and just telling the user that a SessionReset
occurred.
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.
Ah. I missed the context. All good!
This PR fixes #98 by allowing for a list of
TopicFilter
objects to be provided to thesubscribe()
function. EachTopicFilter
is composed ofSubscriptionOptions
and antopic
path. ConvenienceFrom<&str>
has been implemented forTopicFilter
to allow the user to subscribe similar to the previous API.@jordens There's some nuance in allowing the user to specify multiple TopicFilters per subscription request that ripples through the codebase. Let me know what you think about the change. We don't have to support multiple
TopicFilter
s perSUBSCRIBE
if we don't want to.