Skip to content
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

Merged
merged 5 commits into from
Sep 6, 2022
Merged

Conversation

ryan-summers
Copy link
Member

This PR fixes #98 by allowing for a list of TopicFilter objects to be provided to the subscribe() function. Each TopicFilter is composed of SubscriptionOptions and an topic path. Convenience From<&str> has been implemented for TopicFilter 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 TopicFilters per SUBSCRIBE if we don't want to.

Copy link
Member

@jordens jordens left a 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);
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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!

src/design_parameters.rs Outdated Show resolved Hide resolved
@ryan-summers ryan-summers merged commit aef5dc4 into master Sep 6, 2022
@ryan-summers ryan-summers deleted the feature/subscription-flags branch September 6, 2022 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Subscription option flags support
2 participants