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

fix(binding-mqtt): fix incorrect segment indices and change index and… #976

Merged

Conversation

hasanheroglu
Copy link
Contributor

… length values to enums

Closes #874

@danielpeintner
Copy link
Member

@egekorkan can you take a look

Copy link
Member

@danielpeintner danielpeintner left a comment

Choose a reason for hiding this comment

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

Question: Can we come up with a test to avoid regressions in the future?
I am not sure, but maybe some very basic interactions with https://test.mosquitto.org/ ?

Copy link
Member

@relu91 relu91 left a comment

Choose a reason for hiding this comment

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

Changes look good, but before approving I agree with Daniel that it is better to have test. You can add one at the https://github.com/eclipse/thingweb.node-wot/blob/master/packages/binding-mqtt/test/mqtt-client-subscribe-test.integration.ts . There is no need to depend on https://test.mosquitto.org/. Finally, I added a question below.

Comment on lines 42 to 53
enum SegmentLength {
"action" = 3,
"property" = 4,
}

enum SegmentIndex {
"thingName" = 0,
"interactionType" = 1,
"interactionName" = 2,
"interactionExtension" = 3,
}

Copy link
Member

Choose a reason for hiding this comment

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

Can you explain your trail of thoughts to use an enum to model topic parsing?

Copy link
Contributor Author

@hasanheroglu hasanheroglu May 8, 2023

Choose a reason for hiding this comment

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

For me it was really easy to mix up numbers while coding so I thought it would be easier to use something self-explanatory. Since topic segments always have the similar order, I think with enums the code becomes more readable.

Copy link
Member

Choose a reason for hiding this comment

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

Personally I would not have used enums but I will definitely not object if you prefer keeping it.
Note: In other bindings we don't use enums for the same type of hierarchy.

Copy link
Member

Choose a reason for hiding this comment

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

If it is not a problem I would follow the principles of "less surprise" and "consistency". You can use a prefix or suffix to group semantically const. Sorry, for being picky you did a great job already but I think it is worth doing this small refactor.

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 did the change here: 3952483.

@egekorkan
Copy link
Member

I like the changes, thanks @hasanheroglu ! Tests would be indeed very beneficial

@hasanheroglu
Copy link
Contributor Author

To be able to add meaningful tests, #979 needs to be solved first.

Copy link
Member

@relu91 relu91 left a comment

Choose a reason for hiding this comment

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

Thank you really much! it's good to go.

@relu91 relu91 merged commit 397bc9e into eclipse-thingweb:master May 11, 2023
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.

Bug in MQTT topic parsing
4 participants