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

Enable support for MQTT stitcher in stirling #1918

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

ChinmayaSharma-hue
Copy link
Contributor

Summary: This PR adds the stitcher component of MQTT (v5), a newly added protocol.

Related issues: #341

Type of change: /kind feature

Test Plan: Added tests

@ChinmayaSharma-hue ChinmayaSharma-hue requested a review from a team as a code owner May 26, 2024 13:20
Signed-off-by: Chinmay <[email protected]>
Copy link
Member

@ddelnano ddelnano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChinmayaSharma-hue sorry for the late review and really appreciate all your work on the MQTT protocol support!

Copy link
Member

@ddelnano ddelnano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the latest updates! I know this latest round has quite a bit of comments, but stitching is a challenging component and the more thought that's put into the edge cases now will save time when we move onto the next step!

As for the tests that clear the reqs/resps maps before the next batch of assertions, it might be helpful to split each of those into their own test case (TEST(MqttStitchTest, XXX) macro). I assume the map .clears() are there to prevent the earlier "test cases" from causing unrelated failures for the later test code. In my opinion, that is a signal that they should be independent cases and any shared setup should be refactored into another function.

Copy link
Member

@ddelnano ddelnano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for all the hard work on this. This round of feedback is only a few minor things and I expect that after these are addressed we can move forward with merging this!

Comment on lines 719 to 727
} else {
if (type == message_type_t::kRequest) {
state->send[std::tuple<uint32_t, uint32_t>(result->header_fields["packet_identifier"],
result->header_fields["qos"])] = 0;
} else {
state->recv[std::tuple<uint32_t, uint32_t>(result->header_fields["packet_identifier"],
result->header_fields["qos"])] = 0;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to store a key in the state for PUBLISH'es that don't have any dups?

The ::operator[] method will insert into the map if the key doesn't exist. So I believe the += operator will work as expected without the non dup branch.

Comment on lines 115 to 123
state->send[unique_publish_identifier] > 0) {
state->send[unique_publish_identifier] -= 1;
req_frame.consumed = true;
continue;
}

if (req_frame.type == message_type_t::kResponse &&
state->recv[unique_publish_identifier] > 0) {
state->recv[unique_publish_identifier] -= 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to my earlier comment about avoiding excess inserts into state->{recv,send}. Can we use ::find() instead of ::operator[]?

Comment on lines 67 to 68
{0xc0, 0xd0},
// AUTH to AUTH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we decided that we were skipping supporting AUTH frames for now. If that changed, I'm ok with keeping this. However, I'd like to add a comment explaining what the gap is (if any) while it's still fresh in our minds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to remove the mapping from the map itself, and a TODO before the logic of skipping AUTH matching in the stitcher function.

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.

2 participants