-
Notifications
You must be signed in to change notification settings - Fork 674
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
NOISSUE - Adding subtopics filtering in writer services #1072
NOISSUE - Adding subtopics filtering in writer services #1072
Conversation
Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
Codecov Report
@@ Coverage Diff @@
## master #1072 +/- ##
==========================================
+ Coverage 77.93% 77.99% +0.06%
==========================================
Files 95 95
Lines 6743 6685 -58
==========================================
- Hits 5255 5214 -41
+ Misses 1174 1159 -15
+ Partials 314 312 -2
Continue to review full report at Codecov.
|
Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
a5cbaec
to
2ffb670
Compare
…erge both loading methods & returning error) Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
@jonathandreyer update your branch please |
Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
I did not yet go into details, but at the first look this looks over-complicated to me. We must brainstorm to find a simpler solution. This introduces impact, and is not something that I'd like to maintain (at least at the first look). @jonathandreyer can you please describe us your use-case and requirement here in greater detail. From what I understood, you needed to redirect messages to 2 different DBs. Why could not you do it on the channel level? |
I fully understand the first point. Sure, I will try to explain the reason. The explain that, I will take as an example the subtopics in the documentation (https://mainflux.readthedocs.io/en/latest/messaging/#subtopics). In my usage, I have two channels by device (which are provided by bootstrap service) and subtopics for each kind of sended values. I would like store numerical values (related to specific topics, like temperature) in influxDB and string values in another database (mongoDB) for more general information about device, like wake-up, shutdown, etc. With this function (filtering by subtopics), I can select which information I would like to store in which database. |
OK, this is something what I thought. Now second question: what about having just one config file - for example |
@drasko For me, both alternatives are ok. As discussed here (https://github.com/mainflux/mainflux/pull/1072#discussion_r391604923), @manuio think is better to keep both files for retro-compatible reason and also easier to understand. With the resolution of #925, I think the version with one file is OK. |
…method Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
Hi @manuio & @drasko, I have merged both filters files into one file as explain before but now it has no effect. My knowledge in NATS is pretty poor to subscribe in only selected subjects (here: https://github.com/jonathandreyer/mainflux/blob/4c6576193344b82f067a25f22abf9d4ebbc680b5/writers/writer.go#L45). Have you an idea how proceed? |
Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
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.
@jonathandreyer this starts to look good. On the first look just a minor suggestion regarding the docs, but I will analyze with more attention tomorrow.
We will be needing approvals from several maintainers, as this touches lot of code.
Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
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
Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch>
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
Merged! Thanks @jonathandreyer and @manuio |
* Add feature of filtering by subtopics in writer Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Fix mistake Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Refactoring writer sevices Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Rename variables related to filter (channels & subtopics) Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Set default value of filtering when configuration file doesn't exist Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Add a blank line at the end of the file Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Refactor loading filters configuration (moving into writer package, merge both loading methods & returning error) Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Remove useless log Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Change type of variables (channels & subtopics) and simplify loading method Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Add logging error when loading filters Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Simplify return configuration in loading method Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Merge both filter files into one file Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Move loading subjects into writer package Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Add subscribe to selected subjects Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Edit README of writer services Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Keep only subscribe loop Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Use full NATS subjects Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> * Edit comment in subjects files Signed-off-by: Jonathan Dreyer <jonathan.dreyer@cleanenergie.ch> Co-authored-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
What does this do?
Adding subtopic's filtering for each writer service. It is strongly based on channel's filtering.
Which issue(s) does this PR fix/relate to?
Also resolves #925.
List any changes that modify/break current functionality
Have you included tests for your changes?
Did you document any new/modified functionality?
Update readme of each writer service with new
Notes
I have also refactored a little part of the main code of every writer services to centralize duplicate code into writer package.