-
Notifications
You must be signed in to change notification settings - Fork 669
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
MF-596 - Add subtopic to RawMessage #642
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.
Hi @beres, thanks for your contribution. The code looks good, but IMHO there are few things which need improvements:
- As @drasko already mentioned on Gitter you should sign the commits.
- There are few tests which are failing:
# github.com/mainflux/mainflux/readers/influxdb_test
readers/influxdb/messages_test.go:116:27: not enough arguments in call to reader.ReadAll
have (string, uint64, uint64)
want (string, uint64, uint64, map[string]string)
# github.com/mainflux/mainflux/readers/cassandra_test
readers/cassandra/messages_test.go:102:27: not enough arguments in call to reader.ReadAll
have (string, uint64, uint64)
want (string, uint64, uint64, map[string]string)
# github.com/mainflux/mainflux/readers/mongodb_test
readers/mongodb/messages_test.go:109:27: not enough arguments in call to reader.ReadAll
have (string, uint64, uint64)
want (string, uint64, uint64, map[string]string)
You can check if all the test are still passing with make test
. Don't forget to start your docker daemon because the tests are using Dockertest.
You can also run each test separately from the command line with for i.e. GOCACHE=off go test -v -race readers/influxdb/messages_test.go
- There are no tests about the parts regarding the
subtopic
which you've added - Addition of few sentences about the
subtopics
in the user guide would also be nice
Keep up the good work.
Best Regards,
Jovan
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.
overall looks ok
Modified and tested: - cli - http - mqtt - normalizer - all readers - sdk messages - all writers - ws Missing: - coap - lora Signed-off-by: ale <ale@metaverso.org>
- add some test on readers Signed-off-by: ale <ale@metaverso.org>
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.
- update http/transport regexp to match subtopic names with only \w- - update ws/transport regexp like http ones with also the wildcard * and > Signed-off-by: ale <ale@metaverso.org>
Signed-off-by: ale <ale@metaverso.org>
@beres I think you are getting closer. Please take into account @anovakovic01's remarks so we can continue with review and iterations. |
- renamed getDestChannel to fmtSubject - update api/transport and ws/transport route to be more readable - fix mqtt syntax - renamed func andQuery to query as suggested by @anovakovic01 - have a nice we :) Signed-off-by: ale <ale@metaverso.org>
- fix regexp added missing allowed chars - and _ on coap/api/transport - fix subtopic clean suffix / if present on coap/api/transport - improve regexp on http and ws /api/transport, now does not accept url that do not strictly match - add some ws subtopic tests Signed-off-by: ale <ale@metaverso.org>
@beres we are in a hurry with this one - we would like to release 0.8 on Friday. Can you please take in the account the remarks and correct the PR so that we can test it and merge it? |
hey @drasko with last commit all the report of @anovakovic01 have been fixed, did i miss something? |
Signed-off-by: ale <ale@metaverso.org>
Codecov Report
@@ Coverage Diff @@
## master #642 +/- ##
=========================================
- Coverage 87.13% 86.4% -0.74%
=========================================
Files 62 62
Lines 3887 3707 -180
=========================================
- Hits 3387 3203 -184
- Misses 344 346 +2
- Partials 156 158 +2
Continue to review full report at Codecov.
|
…ng.org/doc/go1.10#test Signed-off-by: ale <ale@metaverso.org>
Looks like CI is passing and we are getting close. @anovakovic01 @dusanb94 @nmarcetic @manuio @mteodor please review. |
http/api/transport.go
Outdated
auth mainflux.ThingsServiceClient | ||
errMalformedData = errors.New("malformed request data") | ||
auth mainflux.ThingsServiceClient | ||
channelPartRegExp = regexp.MustCompile(`^/channels/([\w\-]+)/messages((/[^/]+)*)*(\?.*)?$`) |
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 that this ((/[^/]+)*)*
can be simplified with ((/[^/]+)*)?
. Also, @drasko do we want to add support for query parameters in HTTP adapter? I'm not sure that we should allow in subtopic characters such as .
, >
and *
, which are specific to NATS.
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.
actually http does not use query parameters, i use the same regexp for coap/ws/http. If you do not want a specific regexp per adapter, it could be placed in a shared 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.
@beres If you want to do this, topics.go
file in the project root is a good place for that.
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.
@dusanb94 could also be the place for common subtopic function?
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.
@beres If that function is shared and does not accept any adapter-specific arguments, then I'd say yes.
- minor changes Signed-off-by: ale <ale@metaverso.org>
Signed-off-by: ale <ale@metaverso.org>
Signed-off-by: ale <ale@metaverso.org>
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
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
@beres thanks a lot for this important contribution! Good work here. |
* Commit for mainflux-596 Modified and tested: - cli - http - mqtt - normalizer - all readers - sdk messages - all writers - ws Missing: - coap - lora Signed-off-by: ale <ale@metaverso.org> * - fix subtopic name in, when starting with dot, http/ws/mqtt - add some test on readers Signed-off-by: ale <ale@metaverso.org> * - fix string concatenation - update http/transport regexp to match subtopic names with only \w- - update ws/transport regexp like http ones with also the wildcard * and > Signed-off-by: ale <ale@metaverso.org> * added subtopic support to coap adapter Signed-off-by: ale <ale@metaverso.org> * - update replace functions with replaceall when needed - renamed getDestChannel to fmtSubject - update api/transport and ws/transport route to be more readable - fix mqtt syntax - renamed func andQuery to query as suggested by @anovakovic01 - have a nice we :) Signed-off-by: ale <ale@metaverso.org> * - fix error declaration on ws/nat/publisher - fix regexp added missing allowed chars - and _ on coap/api/transport - fix subtopic clean suffix / if present on coap/api/transport - improve regexp on http and ws /api/transport, now does not accept url that do not strictly match - add some ws subtopic tests Signed-off-by: ale <ale@metaverso.org> * - enabled wildcard chars on coap/api/transport - allow use special chars on http and ws api/transport Signed-off-by: ale <ale@metaverso.org> * - use strings.Replace() insted ReplaceAll() Signed-off-by: ale <ale@metaverso.org> * - allow every chars on subtopics - fix replace error on mqtt Signed-off-by: ale <ale@metaverso.org> * fix cassandra test Signed-off-by: ale <ale@metaverso.org> * fix ws test with invalid subtopic Signed-off-by: ale <ale@metaverso.org> * fix invalid GOCACHE in go1.12, replaced by -count 1, see https://golang.org/doc/go1.10#test Signed-off-by: ale <ale@metaverso.org> * - improve regexp on http/ws api/transport - minor changes Signed-off-by: ale <ale@metaverso.org> * - add generic function parseSubtopic on ws/http adapters Signed-off-by: ale <ale@metaverso.org> * - add generic function fmtSubtopic on coap adapter Signed-off-by: ale <ale@metaverso.org>
* Commit for mainflux-596 Modified and tested: - cli - http - mqtt - normalizer - all readers - sdk messages - all writers - ws Missing: - coap - lora Signed-off-by: ale <ale@metaverso.org> * - fix subtopic name in, when starting with dot, http/ws/mqtt - add some test on readers Signed-off-by: ale <ale@metaverso.org> * - fix string concatenation - update http/transport regexp to match subtopic names with only \w- - update ws/transport regexp like http ones with also the wildcard * and > Signed-off-by: ale <ale@metaverso.org> * added subtopic support to coap adapter Signed-off-by: ale <ale@metaverso.org> * - update replace functions with replaceall when needed - renamed getDestChannel to fmtSubject - update api/transport and ws/transport route to be more readable - fix mqtt syntax - renamed func andQuery to query as suggested by @anovakovic01 - have a nice we :) Signed-off-by: ale <ale@metaverso.org> * - fix error declaration on ws/nat/publisher - fix regexp added missing allowed chars - and _ on coap/api/transport - fix subtopic clean suffix / if present on coap/api/transport - improve regexp on http and ws /api/transport, now does not accept url that do not strictly match - add some ws subtopic tests Signed-off-by: ale <ale@metaverso.org> * - enabled wildcard chars on coap/api/transport - allow use special chars on http and ws api/transport Signed-off-by: ale <ale@metaverso.org> * - use strings.Replace() insted ReplaceAll() Signed-off-by: ale <ale@metaverso.org> * - allow every chars on subtopics - fix replace error on mqtt Signed-off-by: ale <ale@metaverso.org> * fix cassandra test Signed-off-by: ale <ale@metaverso.org> * fix ws test with invalid subtopic Signed-off-by: ale <ale@metaverso.org> * fix invalid GOCACHE in go1.12, replaced by -count 1, see https://golang.org/doc/go1.10#test Signed-off-by: ale <ale@metaverso.org> * - improve regexp on http/ws api/transport - minor changes Signed-off-by: ale <ale@metaverso.org> * - add generic function parseSubtopic on ws/http adapters Signed-off-by: ale <ale@metaverso.org> * - add generic function fmtSubtopic on coap adapter Signed-off-by: ale <ale@metaverso.org>
What does this do?
The patch add subtopic support to the following components
Not updated:
Which issue(s) does this PR fix/relate to?
Put here
Resolves #XXX
to auto-close the issue that your PR fixes (if such)List any changes that modify/break current functionality
Have you included tests for your changes?
Did you document any new/modified functionality?
Notes