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

MF-596 - Add subtopic to RawMessage #642

Merged
merged 18 commits into from
Mar 15, 2019
Merged

Conversation

beres
Copy link
Contributor

@beres beres commented Mar 7, 2019

What does this do?

The patch add subtopic support to the following components

  • cli
  • http
  • mqtt
  • normalizer
  • all readers
  • sdk messages
  • all writers
  • ws

Not updated:

  • coap
  • lora

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

@drasko drasko changed the title MF-596 MF-596 - Add subtopic to RawMessage Mar 7, 2019
Copy link
Collaborator

@chombium chombium left a 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:

  1. As @drasko already mentioned on Gitter you should sign the commits.
  2. 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

  1. There are no tests about the parts regarding the subtopic which you've added
  2. Addition of few sentences about the subtopics in the user guide would also be nice

Keep up the good work.

Best Regards,
Jovan

Copy link
Contributor

@mteodor mteodor left a comment

Choose a reason for hiding this comment

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

overall looks ok

mqtt/mqtt.js Outdated Show resolved Hide resolved
mqtt/mqtt.js Show resolved Hide resolved
writers/cassandra/init.go Show resolved Hide resolved
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>
Copy link
Collaborator

@dborovcanin dborovcanin 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 contribution, @beres!

Please sign your commits, add the reference to an existing issue in PR description (#596), remove all TODOs from the code and check CI.

cli/message.go Outdated Show resolved Hide resolved
http/api/transport.go Outdated Show resolved Hide resolved
http/api/transport.go Outdated Show resolved Hide resolved
http/nats/publisher.go Show resolved Hide resolved
readers/cassandra/messages.go Outdated Show resolved Hide resolved
readers/influxdb/messages.go Outdated Show resolved Hide resolved
http/api/transport.go Outdated Show resolved Hide resolved
readers/cassandra/messages.go Outdated Show resolved Hide resolved
- 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>
http/api/transport.go Outdated Show resolved Hide resolved
http/api/transport.go Outdated Show resolved Hide resolved
mqtt/mqtt.js Outdated Show resolved Hide resolved
readers/cassandra/messages_test.go Outdated Show resolved Hide resolved
readers/influxdb/messages_test.go Outdated Show resolved Hide resolved
readers/mocks/messages.go Outdated Show resolved Hide resolved
readers/mongodb/messages_test.go Outdated Show resolved Hide resolved
ws/api/transport.go Outdated Show resolved Hide resolved
ws/nats/publisher.go Outdated Show resolved Hide resolved
ws/nats/publisher.go Outdated Show resolved Hide resolved
@drasko
Copy link
Contributor

drasko commented Mar 8, 2019

@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>
@drasko
Copy link
Contributor

drasko commented Mar 11, 2019

@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?

@beres
Copy link
Contributor Author

beres commented Mar 12, 2019

hey @drasko with last commit all the report of @anovakovic01 have been fixed, did i miss something?

ws/api/transport.go Outdated Show resolved Hide resolved
Signed-off-by: ale <ale@metaverso.org>
@codecov-io
Copy link

codecov-io commented Mar 13, 2019

Codecov Report

Merging #642 into master will decrease coverage by 0.73%.
The diff coverage is 78.74%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
writers/cassandra/init.go 60% <ø> (-18.58%) ⬇️
readers/api/requests.go 100% <ø> (ø) ⬆️
readers/cassandra/messages.go 91.66% <100%> (+2.43%) ⬆️
writers/mongodb/messages.go 100% <100%> (ø) ⬆️
readers/mongodb/messages.go 91.3% <100%> (-3.44%) ⬇️
readers/api/endpoint.go 100% <100%> (ø) ⬆️
writers/influxdb/messages.go 85.71% <100%> (-0.78%) ⬇️
ws/adapter.go 93.75% <100%> (ø) ⬆️
writers/cassandra/messages.go 100% <100%> (ø) ⬆️
sdk/go/message.go 38.59% <35.71%> (-10.02%) ⬇️
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f09701...d746557. Read the comment docs.

@drasko
Copy link
Contributor

drasko commented Mar 13, 2019

Looks like CI is passing and we are getting close. @anovakovic01 @dusanb94 @nmarcetic @manuio @mteodor please review.

dborovcanin
dborovcanin previously approved these changes Mar 14, 2019
coap/api/transport.go Show resolved Hide resolved
http/api/transport.go Outdated Show resolved Hide resolved
auth mainflux.ThingsServiceClient
errMalformedData = errors.New("malformed request data")
auth mainflux.ThingsServiceClient
channelPartRegExp = regexp.MustCompile(`^/channels/([\w\-]+)/messages((/[^/]+)*)*(\?.*)?$`)
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Collaborator

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.

Copy link
Contributor Author

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?

Copy link
Collaborator

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>
@drasko drasko added this to the 0.9.0 milestone Mar 14, 2019
@nmarcetic nmarcetic modified the milestones: 0.9.0, 0.8.0 Mar 14, 2019
Copy link
Contributor

@anovakovic01 anovakovic01 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@drasko drasko left a comment

Choose a reason for hiding this comment

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

LGTM

@drasko drasko requested review from chombium and manuio March 14, 2019 21:05
@drasko
Copy link
Contributor

drasko commented Mar 14, 2019

@manuio @chombium we need your positive reviews to merge this PR

Copy link
Contributor

@manuio manuio left a comment

Choose a reason for hiding this comment

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

LGTM

@nmarcetic nmarcetic merged commit 61b2d6b into absmach:master Mar 15, 2019
@drasko
Copy link
Contributor

drasko commented Mar 15, 2019

@beres thanks a lot for this important contribution! Good work here.

@beres beres deleted the mainflux-596 branch April 5, 2019 08:09
davide83 pushed a commit to davide83/mainflux that referenced this pull request May 13, 2019
* 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>
manuio pushed a commit that referenced this pull request Oct 12, 2020
* 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>
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.

9 participants