mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-24 13:48:49 +08:00
NOISSUE - RabbitMQ build and deployment (#1570)
* Initial commit of adding rabbitmq broker Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Initial commit of adding rabbitmq broker Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Initial commit for tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Bump up tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Add more tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Add go routines Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Initial commit of adding rabbitmq broker Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Initial commit of adding rabbitmq broker Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Initial commit for tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Bump up tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Add more tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Add go routines Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Fix tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Fix with wait groups Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * unsubscribe to stop delivering messages Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Remove exclusivity Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Implement cancel mechanisms Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Queuename as parameter Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Queuename as parameter Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Initial commit Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Remove broker type Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Configure broker with makefile Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Check if we have changed MESSAGE_BROKER_FILE~ Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Set nats automatically Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Catching null and invalid broker type Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Remove unused fmt Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Fix tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Nats Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * unexport constants Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change routingkey Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Remove wait groups Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * protecting map Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Add publisher to pubsub Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change proto library Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Fix typos Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Reduce pubsub tests based on implementation Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Remove channel cancel Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Export constant Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Embedding publisher into pubsub Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Naming publisher Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Update rabbitmq subscriber interface Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * using publisher composition Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change contenttype Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * rename topic for publish and subscribe Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change errors to lower case Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change errors to lower case Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * export errors Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * queue per subscription Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * queue per subscription Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Merge branch 'master' into RabbitMQ-deployment Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * rename nats to broker Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change routing method Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Direct method with one exchange to many queues, one consumer per queue Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1263 - Move repeating errors to the separate package (#1540) * MF-1263 - Mv duplicated errors to pkg/errors Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Revert test build flags Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix merge Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix comment Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * NOISSUE - Fix auth members list response (#1555) * NOISSUE - Fix auth members list response Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Move group type next to page details Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Rm membersRes Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1261 - Use StatusUnauthorized for authn and StatusForbidden for authz (#1538) * MF-1261 - Use StatusUnauthorized for authn and StatusForbidden for authz Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * ErrExternalKey typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Rename ErrUnauthorizedAcces -> ErrAuthentication Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix bootstrap error Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix status code in openapi Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix test description Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix test description Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix test description Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Add errors cases Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix status codes Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Add gRPC stutus code Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix tests description Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix openapi and encodeError Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix grpc message Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix test descriptions Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Revert sdk error Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1059 - Add TLS support for email (#1560) * Use gomail package for sending emails Signed-off-by: Ivan Milosevic <iva@blokovi.com> * remove print err Signed-off-by: Ivan Milosevic <iva@blokovi.com> * Add vendor Signed-off-by: Ivan Milosevic <iva@blokovi.com> * Rename email structure remove logger Signed-off-by: Ivan Milosevic <iva@blokovi.com> * typo in var name Signed-off-by: Ivan Milosevic <iva@blokovi.com> * rename var Signed-off-by: Ivan Milosevic <iva@blokovi.com> * remove MF_EMAIL_SECRET Signed-off-by: Ivan Milosevic <iva@blokovi.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * NOISSUE - Refactor MQTT subscriber (#1561) * correct suscriber interface validator + refactore token error handling Signed-off-by: tzzed <zerouali.t@gmail.com> * apply review suggestion Signed-off-by: tzzed <zerouali.t@gmail.com> Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1257 - Access messages from readers endpoint with user access token (#1470) * remove owner id Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add user auth for db reader Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * add user auth for db reader Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * enable mongodb reader for user token reading Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * use uuid check for auth switch between thing key and user tok Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * enable user token reading Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * revert to correct version Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * fix endpoint test, add additional tests Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * remove logs,dead code Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * fix logging messages Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * remove auth interface, add authorization header type Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * update api doc Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * remove unused package Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * some refactor of cases for authorization switch Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * correct description in openapi Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * fix endpoint test to match auth service change Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * some rename Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * initialize auth url Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * add env variables for auth service Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * fix spelling Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * Things prefix and no prefix for Thing authorization, Bearer for user Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * update readme file Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * fix default things grpc port Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * enable user reading for timescaledb Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * remove not used error Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * improve errors Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * refactor authorize Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * add chanID check Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * inline some error checking Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * fixing errors Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * fixing errors Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * improve test case description Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * remove test code Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * dont inline Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * refactor a bit encodeError Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * remove unused error Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * remove unused error Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * fix things auth grpc url Signed-off-by: mteodor <mirko.teodorovic@gmail.com> * rename variables for header prefix Signed-off-by: mteodor <mirko.teodorovic@gmail.com> Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Initial commit of adding rabbitmq broker Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Initial commit of adding rabbitmq broker Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Initial commit for tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Bump up tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Add more tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Add go routines Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Initial commit of adding rabbitmq broker Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Initial commit for tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Bump up tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Add more tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Add go routines Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Fix tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Fix with wait groups Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * unsubscribe to stop delivering messages Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Remove exclusivity Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1551 - Fix Cobra usage commands and clean unnecessary struct types (#1558) * MF-1551 - Fix Cobra usage commands and clean unnecessary struct types Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Use linux syntax for cmd usage description Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix cmd.Use Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * NOISSUE - Separate Keto hosts for read and write (#1563) * Separate keto hosts for read and write Signed-off-by: Ivan Milosevic <iva@blokovi.com> * update readme with new envars Signed-off-by: Ivan Milosevic <iva@blokovi.com> * rename read connection name Signed-off-by: Ivan Milosevic <iva@blokovi.com> Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> Co-authored-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Update dependencies (#1564) Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1240 - Return to service transport layer only service errors (#1559) * MF-1240 - Return to service transport layer only service errors Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Remove unecessary errors Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Rm duplicated errors and fix transport Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Revert http endpoint_test Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix conflict Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Implement cancel mechanisms Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Queuename as parameter Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Queuename as parameter Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1469 - Indicate proper authentication scheme in Authorization header (#1523) * MF-1469 - Indicate proper authentication scheme in Authorization header Signed-off-by: Stefan Kovacevic <jen2tri@gmail.com> * Fixing the remarks on the last push Signed-off-by: Stefan Kovacevic <jen2tri@gmail.com> * Remove Bearer prefix in all services and fix tests Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix remarks Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> Co-authored-by: Manuel Imperiale <manuel.imperiale@gmail.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * NOISSUE - Add nats wrapper for COAP (#1569) * Add nats wrapper for COAP Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Pass pubsub as argument Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Defer close connection Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Defer close connection Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Rename endpoint to topic Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1348 - Add transport errors logging (#1544) * MF-1348 - Add go-kit transport level logging Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix merge Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix remark Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix go test flags Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Use httputil errors in things and http service Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix SDK tests Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Use httputil errors in certs and provision service Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Use httputil errors in consumers service Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * General renaming and add ErrMissingToken Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Rename httputil -> apiutil and use errors in users servive Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Use apiutil errors in auth, bootstrap, readers, things and twins Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Replace errors.Contain by comparison Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix remarks Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Simplify validateID Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Simplify validateID Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Simplify and rename ExtractAuthToken -> ExtractBearerToken Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix readers Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix auth key test and remarks Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Improve comment Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Simplify validateUUID check Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1567 - Use Bearer, Thing or Basic scheme in Authorization header (#1568) Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1565 - Document Bearer, Thing and Basic Authorization header (#1566) * MF-1565 - Document Bearer Authorization header Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix auth, bootstrap, http and readers openapi Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix openapi Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Add enc key for bootstrap Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Use global security Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix bearer formats Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Polish descriptions Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix boostrap and typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> Co-authored-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1575 Add 'Name' field to ListMembers response in things svc (#1576) Signed-off-by: Ivan Balboteo <ivan@submer.com> Co-authored-by: Ivan Balboteo <ivan@submer.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1580 - Influxdb Writer changes format of update-time to string (#1581) * - MF-1580 - Modified consumers/writers/influxdb/fields.go - influxdb-writer used to update data type of update-time to string - Commented line 12 of consumers/writers/influxdb/fields.go to resolve uneccessary data type conversion issue Signed-off-by: Hasan Tariq <hasantariqashraf@gmail.com> * - MF-1580 - Removed strconv package from consumers/writers/influxdb/fields.go since it is no longer needed - Removed line 12 from consumers/writers/influxdb/fields.go - Replaced retrun value of updateTime with msg.UpdateTime (line 16 in fields.go) Signed-off-by: Hasan Tariq <hasantariqashraf@gmail.com> * Fix InflxuDB readers Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Co-authored-by: Hasan Tariq <hasant@plcgroup.com> Co-authored-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * NOISSUE - Unify MF_INFLUX_READER_DB_HOST and MF_INFLUX_WRITER_DB_HOST envars (#1585) Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * NOISSUE - Fix CoAP adapter (#1572) * Revert "NOISSUE - Add nats wrapper for COAP (#1569)" This reverts commit cc5d5195ab27fa94270ada616487b7053fd9c7bd. Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix CoAP adapter Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Update CoAP observation cancel Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix observe Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix GET handling Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Revert authorization Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Use constants instead of magic numbers Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Remove an empty line Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Extract special observe value to constant Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1582 - Fix lora-adapter MQTT client (#1583) * MF-1582 - Fix lora-adapter MQTT clien Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Add timeout config to the mqtt subscriber Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Rm comment Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Add sub timeout Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * NOISSUE - Update changelog and readme for release 0.13.0 (#1592) * Update release example Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Update changelog and examples for 0.13.0 release Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Update VerneMQ release (#1593) Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * NOISSUE - Update changelog for release 0.13.0 (#1595) Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * unexport constants Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change routingkey Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Remove wait groups Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * protecting map Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Add publisher to pubsub Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change proto library Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Fix typos Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Reduce pubsub tests based on implementation Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Remove channel cancel Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Export constant Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * NOISSUE - Move invariant statements out of loop for cassandra-writer (#1596) Signed-off-by: fuzhy <fuzhy1997@outlook.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Embedding publisher into pubsub Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Naming publisher Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * NOISSUE - Fix Nginx entrypoint script (#1597) * Fix Nginx entrypoint script Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Update dependencies Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Fix NginX entrypoint Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Revert Makefile changes Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1525 - Add graceful stop for HTTP and GRPC servers (#1548) * Add : errgroup to cmd/auth Signed-off-by: Arvindh <arvindh91@gmail.com> * Add : Handle graceful stop for auth service Remove : errgroups from auth service Signed-off-by: Arvindh <arvindh91@gmail.com> * Add : Wait till server shutdown Signed-off-by: Arvindh <arvindh91@gmail.com> * Change : instead of waitgroup changed to errgroups Signed-off-by: Arvindh <arvindh91@gmail.com> * change : KillSignalHandler return type to error Signed-off-by: Arvindh <arvindh91@gmail.com> * Empty Commit Signed-off-by: Arvindh <arvindh91@gmail.com> * Add : Context to http server shutdown Rename : varaible from proto to protocol Signed-off-by: Arvindh <arvindh91@gmail.com> * change : to default log level Signed-off-by: Arvindh <arvindh91@gmail.com> * Add : Sign-off Signed-off-by: Arvindh <arvindh91@gmail.com> * Add: graceful stop of http and grpc server Signed-off-by: Arvindh <arvindh91@gmail.com> * Fix: typos and caps Signed-off-by: Arvindh <arvindh91@gmail.com> * Add: Signed-off Signed-off-by: Arvindh <arvindh91@gmail.com> * Rename: Func KillSignalHandler to SignalHandler Add: SIGABRT Signed-off-by: Arvindh <arvindh91@gmail.com> * Fix: auth service Signed-off-by: Arvindh <arvindh91@gmail.com> * Add: timeout for grpc gracefulstop Fix: typos Signed-off-by: Arvindh <arvindh91@gmail.com> * Add: .vscode folder to git ignore Signed-off-by: Arvindh <arvindh91@gmail.com> * change: variable name to stopWaitTime Signed-off-by: Arvindh <arvindh91@gmail.com> * remove: .vscode folder Signed-off-by: Arvindh <arvindh91@gmail.com> * remove: .vscode from .gitignore Signed-off-by: Arvindh <arvindh91@gmail.com> * Add : logger to handlers Signed-off-by: Arvindh <arvindh91@gmail.com> * Add : New line at end of .gitignore file Signed-off-by: Arvindh <arvindh91@gmail.com> * Fix : variable naming Add : graceful stop for timescale Signed-off-by: Arvindh <arvindh91@gmail.com> * Remove : unsued NATS library from import Signed-off-by: Arvindh <arvindh91@gmail.com> * Move: "https" and "https" to moved to const var Signed-off-by: Arvindh <arvindh91@gmail.com> * Move: "http" and "https" to moved to const var Signed-off-by: Arvindh <arvindh91@gmail.com> * update: branch with master Signed-off-by: Arvindh <arvindh91@gmail.com> Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> Co-authored-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF-1588 - Update Subscriber interface (#1598) * Initial commit Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Update subscriber interface Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com> * Add tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Add tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * check subscription map Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Check topic id after topic Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * reword description Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Setup empty queue Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change mqtt implementation Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Switch statements Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Simplify Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change mqtt subscriber Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Protect subscription map Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Fix subscription Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Set client id Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Format Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change delete method Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Update rabbitmq subscriber interface Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * using publisher composition Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change contenttype Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * rename topic for publish and subscribe Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change errors to lower case Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change errors to lower case Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * export errors Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * MF - 1590 - Fix fetching list of users with a zero limit (#1594) * Add max and min limit size Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Format Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Format Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * NOISSUE - Retrieve client key on cert issuing (#1607) Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * fix bug (#1604) Signed-off-by: zhangchuanfeng <654300242@qq.com> Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * queue per subscription Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * queue per subscription Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change routing method Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Direct method with one exchange to many queues, one consumer per queue Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * ♻️ Not casting data Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * ✏️ Fix typo Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * ♻️ remove passed queue name Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * 🔥 removing echange kind Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Combine tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Refactor unsubscribe method Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Fix merge conflict Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * ✅ sub and unsub to dummy topic Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * generate client id from topic and ID Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Rename topicID to clientID Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * update tests Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * merge changes Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * ♻️ rename constant and variable declaration Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * rename to brokers Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * ♻️ Rename brokers Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change mqtt implementation Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Rename broker to brokers Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * include nats port Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * move to build tags Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * move to build tags Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * add nats build tag to test Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * \n at the end of file Signed-off-by: GitHub <noreply@github.com> * Add init function Signed-off-by: GitHub <noreply@github.com> * Add init function Signed-off-by: GitHub <noreply@github.com> * broker url automatically Signed-off-by: GitHub <noreply@github.com> * make nats as the default broker Signed-off-by: GitHub <noreply@github.com> * Updated publisher and subscriber interface Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Add error to close Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Change image version and let user define URI Signed-off-by: GitHub <noreply@github.com> * make broker url configurable Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * add compile check Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * rabbitmq check Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * default broker to nats Signed-off-by: GitHub <noreply@github.com> * change broker url in docker compose Signed-off-by: GitHub <noreply@github.com> * Fix ci Signed-off-by: GitHub <noreply@github.com> * fix makefile Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Fix env var and ci Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Fix ci Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> * Fix consts Signed-off-by: 0x6f736f646f <blackd0t@protonmail.com> Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com> Co-authored-by: Manuel Imperiale <manuel.Imperiale@gmail.com> Co-authored-by: Ivan Milošević <iva@blokovi.com> Co-authored-by: __touk__ <zerouali.t@gmail.com> Co-authored-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> Co-authored-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com> Co-authored-by: stefankovacevic123 <jen2tri@gmail.com> Co-authored-by: ibalboteo <ivanbalboteo@gmail.com> Co-authored-by: Ivan Balboteo <ivan@submer.com> Co-authored-by: Hasan98-git <67228396+Hasan98-git@users.noreply.github.com> Co-authored-by: Hasan Tariq <hasant@plcgroup.com> Co-authored-by: fuzhy <fuzhy1997@outlook.com> Co-authored-by: Arvindh <30824765+arvindh123@users.noreply.github.com> Co-authored-by: 张传峰 <59160162+zhang-chuanfeng@users.noreply.github.com>
This commit is contained in:
parent
9a87e5cd1f
commit
5c495238a6
17
Makefile
17
Makefile
@ -14,9 +14,15 @@ VERSION ?= $(shell git describe --abbrev=0 --tags)
|
||||
COMMIT ?= $(shell git rev-parse HEAD)
|
||||
TIME ?= $(shell date +%F_%T)
|
||||
|
||||
ifneq ($(MF_BROKER_TYPE),)
|
||||
MF_BROKER_TYPE := $(MF_BROKER_TYPE)
|
||||
else
|
||||
MF_BROKER_TYPE=nats
|
||||
endif
|
||||
|
||||
define compile_service
|
||||
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) \
|
||||
go build -mod=vendor -ldflags "-s -w \
|
||||
go build -mod=vendor -tags $(MF_BROKER_TYPE) -ldflags "-s -w \
|
||||
-X 'github.com/mainflux/mainflux.BuildTime=$(TIME)' \
|
||||
-X 'github.com/mainflux/mainflux.Version=$(VERSION)' \
|
||||
-X 'github.com/mainflux/mainflux.Commit=$(COMMIT)'" \
|
||||
@ -111,4 +117,13 @@ rundev:
|
||||
cd scripts && ./run.sh
|
||||
|
||||
run:
|
||||
ifeq ("$(MF_BROKER_TYPE)", "rabbitmq")
|
||||
sed -i "s,file: brokers/.*.yml,file: brokers/rabbitmq.yml," docker/docker-compose.yml
|
||||
sed -i "s,MF_BROKER_URL: .*,MF_BROKER_URL: $$\{MF_RABBITMQ_URL\}," docker/docker-compose.yml
|
||||
else ifeq ("$(MF_BROKER_TYPE)", "nats")
|
||||
sed -i "s,file: brokers/.*.yml,file: brokers/nats.yml," docker/docker-compose.yml
|
||||
sed -i "s,MF_BROKER_URL: .*,MF_BROKER_URL: $$\{MF_NATS_URL\}," docker/docker-compose.yml
|
||||
else
|
||||
echo "Invalid broker type"; exit 1
|
||||
endif
|
||||
docker-compose -f docker/docker-compose.yml up
|
||||
|
@ -7,7 +7,7 @@ info:
|
||||
version: '1.0.0'
|
||||
description: |
|
||||
MQTT adapter provides an MQTT API for sending messages through the platform. MQTT adapter uses [mProxy](https://github.com/mainflux/mproxy) for proxying traffic between client and MQTT broker.
|
||||
Additionally, the MQTT adapter and the NATS message broker are replicating the traffic between brokers.
|
||||
Additionally, the MQTT adapter and the message broker are replicating the traffic between brokers.
|
||||
|
||||
defaultContentType: application/json
|
||||
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"github.com/mainflux/mainflux/consumers/writers/cassandra"
|
||||
"github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/brokers"
|
||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
@ -31,7 +31,7 @@ const (
|
||||
sep = ","
|
||||
stopWaitTime = 5 * time.Second
|
||||
|
||||
defNatsURL = "nats://localhost:4222"
|
||||
defBrokerURL = "nats://localhost:4222"
|
||||
defLogLevel = "error"
|
||||
defPort = "8180"
|
||||
defCluster = "127.0.0.1"
|
||||
@ -41,7 +41,7 @@ const (
|
||||
defDBPort = "9042"
|
||||
defConfigPath = "/config.toml"
|
||||
|
||||
envNatsURL = "MF_NATS_URL"
|
||||
envBrokerURL = "MF_BROKER_URL"
|
||||
envLogLevel = "MF_CASSANDRA_WRITER_LOG_LEVEL"
|
||||
envPort = "MF_CASSANDRA_WRITER_PORT"
|
||||
envCluster = "MF_CASSANDRA_WRITER_DB_CLUSTER"
|
||||
@ -53,7 +53,7 @@ const (
|
||||
)
|
||||
|
||||
type config struct {
|
||||
natsURL string
|
||||
brokerURL string
|
||||
logLevel string
|
||||
port string
|
||||
configPath string
|
||||
@ -70,9 +70,9 @@ func main() {
|
||||
log.Fatalf(err.Error())
|
||||
}
|
||||
|
||||
pubSub, err := nats.NewPubSub(cfg.natsURL, "", logger)
|
||||
pubSub, err := brokers.NewPubSub(cfg.brokerURL, "", logger)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to connect to message broker: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer pubSub.Close()
|
||||
@ -116,7 +116,7 @@ func loadConfig() config {
|
||||
}
|
||||
|
||||
return config{
|
||||
natsURL: mainflux.Env(envNatsURL, defNatsURL),
|
||||
brokerURL: mainflux.Env(envBrokerURL, defBrokerURL),
|
||||
logLevel: mainflux.Env(envLogLevel, defLogLevel),
|
||||
port: mainflux.Env(envPort, defPort),
|
||||
configPath: mainflux.Env(envConfigPath, defConfigPath),
|
||||
|
@ -19,8 +19,8 @@ import (
|
||||
"github.com/mainflux/mainflux/coap"
|
||||
"github.com/mainflux/mainflux/coap/api"
|
||||
logger "github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/brokers"
|
||||
thingsapi "github.com/mainflux/mainflux/things/api/auth/grpc"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
gocoap "github.com/plgd-dev/go-coap/v2"
|
||||
@ -35,7 +35,7 @@ const (
|
||||
stopWaitTime = 5 * time.Second
|
||||
|
||||
defPort = "5683"
|
||||
defNatsURL = "nats://localhost:4222"
|
||||
defBrokerURL = "nats://localhost:4222"
|
||||
defLogLevel = "error"
|
||||
defClientTLS = "false"
|
||||
defCACerts = ""
|
||||
@ -44,7 +44,7 @@ const (
|
||||
defThingsAuthTimeout = "1s"
|
||||
|
||||
envPort = "MF_COAP_ADAPTER_PORT"
|
||||
envNatsURL = "MF_NATS_URL"
|
||||
envBrokerURL = "MF_BROKER_URL"
|
||||
envLogLevel = "MF_COAP_ADAPTER_LOG_LEVEL"
|
||||
envClientTLS = "MF_COAP_ADAPTER_CLIENT_TLS"
|
||||
envCACerts = "MF_COAP_ADAPTER_CA_CERTS"
|
||||
@ -55,7 +55,7 @@ const (
|
||||
|
||||
type config struct {
|
||||
port string
|
||||
natsURL string
|
||||
brokerURL string
|
||||
logLevel string
|
||||
clientTLS bool
|
||||
caCerts string
|
||||
@ -82,9 +82,9 @@ func main() {
|
||||
|
||||
tc := thingsapi.NewClient(conn, thingsTracer, cfg.thingsAuthTimeout)
|
||||
|
||||
nps, err := nats.NewPubSub(cfg.natsURL, "", logger)
|
||||
nps, err := brokers.NewPubSub(cfg.brokerURL, "", logger)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to connect to message broker: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer nps.Close()
|
||||
@ -142,7 +142,7 @@ func loadConfig() config {
|
||||
}
|
||||
|
||||
return config{
|
||||
natsURL: mainflux.Env(envNatsURL, defNatsURL),
|
||||
brokerURL: mainflux.Env(envBrokerURL, defBrokerURL),
|
||||
port: mainflux.Env(envPort, defPort),
|
||||
logLevel: mainflux.Env(envLogLevel, defLogLevel),
|
||||
clientTLS: tls,
|
||||
|
@ -22,7 +22,7 @@ import (
|
||||
"github.com/mainflux/mainflux/http/api"
|
||||
"github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/brokers"
|
||||
thingsapi "github.com/mainflux/mainflux/things/api/auth/grpc"
|
||||
"github.com/opentracing/opentracing-go"
|
||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
||||
@ -38,7 +38,7 @@ const (
|
||||
defClientTLS = "false"
|
||||
defCACerts = ""
|
||||
defPort = "8180"
|
||||
defNatsURL = "nats://localhost:4222"
|
||||
defBrokerURL = "nats://localhost:4222"
|
||||
defJaegerURL = ""
|
||||
defThingsAuthURL = "localhost:8183"
|
||||
defThingsAuthTimeout = "1s"
|
||||
@ -47,14 +47,14 @@ const (
|
||||
envClientTLS = "MF_HTTP_ADAPTER_CLIENT_TLS"
|
||||
envCACerts = "MF_HTTP_ADAPTER_CA_CERTS"
|
||||
envPort = "MF_HTTP_ADAPTER_PORT"
|
||||
envNatsURL = "MF_NATS_URL"
|
||||
envBrokerURL = "MF_BROKER_URL"
|
||||
envJaegerURL = "MF_JAEGER_URL"
|
||||
envThingsAuthURL = "MF_THINGS_AUTH_GRPC_URL"
|
||||
envThingsAuthTimeout = "MF_THINGS_AUTH_GRPC_TIMEOUT"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
natsURL string
|
||||
brokerURL string
|
||||
logLevel string
|
||||
port string
|
||||
clientTLS bool
|
||||
@ -83,9 +83,9 @@ func main() {
|
||||
thingsTracer, thingsCloser := initJaeger("things", cfg.jaegerURL, logger)
|
||||
defer thingsCloser.Close()
|
||||
|
||||
pub, err := nats.NewPublisher(cfg.natsURL)
|
||||
pub, err := brokers.NewPublisher(cfg.brokerURL)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to connect to message broker: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer pub.Close()
|
||||
@ -139,7 +139,7 @@ func loadConfig() config {
|
||||
}
|
||||
|
||||
return config{
|
||||
natsURL: mainflux.Env(envNatsURL, defNatsURL),
|
||||
brokerURL: mainflux.Env(envBrokerURL, defBrokerURL),
|
||||
logLevel: mainflux.Env(envLogLevel, defLogLevel),
|
||||
port: mainflux.Env(envPort, defPort),
|
||||
clientTLS: tls,
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"github.com/mainflux/mainflux/consumers/writers/influxdb"
|
||||
"github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/brokers"
|
||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
@ -28,7 +28,7 @@ const (
|
||||
svcName = "influxdb-writer"
|
||||
stopWaitTime = 5 * time.Second
|
||||
|
||||
defNatsURL = "nats://localhost:4222"
|
||||
defBrokerURL = "nats://localhost:4222"
|
||||
defLogLevel = "error"
|
||||
defPort = "8180"
|
||||
defDB = "mainflux"
|
||||
@ -38,7 +38,7 @@ const (
|
||||
defDBPass = "mainflux"
|
||||
defConfigPath = "/config.toml"
|
||||
|
||||
envNatsURL = "MF_NATS_URL"
|
||||
envBrokerURL = "MF_BROKER_URL"
|
||||
envLogLevel = "MF_INFLUX_WRITER_LOG_LEVEL"
|
||||
envPort = "MF_INFLUX_WRITER_PORT"
|
||||
envDB = "MF_INFLUXDB_DB"
|
||||
@ -50,7 +50,7 @@ const (
|
||||
)
|
||||
|
||||
type config struct {
|
||||
natsURL string
|
||||
brokerURL string
|
||||
logLevel string
|
||||
port string
|
||||
dbName string
|
||||
@ -71,9 +71,9 @@ func main() {
|
||||
log.Fatalf(err.Error())
|
||||
}
|
||||
|
||||
pubSub, err := nats.NewPubSub(cfg.natsURL, "", logger)
|
||||
pubSub, err := brokers.NewPubSub(cfg.brokerURL, "", logger)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to connect to message broker: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer pubSub.Close()
|
||||
@ -115,7 +115,7 @@ func main() {
|
||||
|
||||
func loadConfigs() (config, influxdata.HTTPConfig) {
|
||||
cfg := config{
|
||||
natsURL: mainflux.Env(envNatsURL, defNatsURL),
|
||||
brokerURL: mainflux.Env(envBrokerURL, defBrokerURL),
|
||||
logLevel: mainflux.Env(envLogLevel, defLogLevel),
|
||||
port: mainflux.Env(envPort, defPort),
|
||||
dbName: mainflux.Env(envDB, defDB),
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"github.com/mainflux/mainflux/lora/api"
|
||||
"github.com/mainflux/mainflux/lora/mqtt"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/brokers"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
|
||||
@ -34,11 +34,11 @@ const (
|
||||
defLogLevel = "error"
|
||||
defHTTPPort = "8180"
|
||||
defLoraMsgURL = "tcp://localhost:1883"
|
||||
defBrokerURL = "nats://localhost:4222"
|
||||
defLoraMsgTopic = "application/+/device/+/event/up"
|
||||
defLoraMsgUser = ""
|
||||
defLoraMsgPass = ""
|
||||
defLoraMsgTimeout = "30s"
|
||||
defNatsURL = "nats://localhost:4222"
|
||||
defESURL = "localhost:6379"
|
||||
defESPass = ""
|
||||
defESDB = "0"
|
||||
@ -49,11 +49,11 @@ const (
|
||||
|
||||
envHTTPPort = "MF_LORA_ADAPTER_HTTP_PORT"
|
||||
envLoraMsgURL = "MF_LORA_ADAPTER_MESSAGES_URL"
|
||||
envBrokerURL = "MF_BROKER_URL"
|
||||
envLoraMsgTopic = "MF_LORA_ADAPTER_MESSAGES_TOPIC"
|
||||
envLoraMsgUser = "MF_LORA_ADAPTER_MESSAGES_USER"
|
||||
envLoraMsgPass = "MF_LORA_ADAPTER_MESSAGES_PASS"
|
||||
envLoraMsgTimeout = "MF_LORA_ADAPTER_MESSAGES_TIMEOUT"
|
||||
envNatsURL = "MF_NATS_URL"
|
||||
envLogLevel = "MF_LORA_ADAPTER_LOG_LEVEL"
|
||||
envESURL = "MF_THINGS_ES_URL"
|
||||
envESPass = "MF_THINGS_ES_PASS"
|
||||
@ -71,11 +71,11 @@ const (
|
||||
type config struct {
|
||||
httpPort string
|
||||
loraMsgURL string
|
||||
brokerURL string
|
||||
loraMsgUser string
|
||||
loraMsgPass string
|
||||
loraMsgTopic string
|
||||
loraMsgTimeout time.Duration
|
||||
natsURL string
|
||||
logLevel string
|
||||
esURL string
|
||||
esPass string
|
||||
@ -102,9 +102,9 @@ func main() {
|
||||
esConn := connectToRedis(cfg.esURL, cfg.esPass, cfg.esDB, logger)
|
||||
defer esConn.Close()
|
||||
|
||||
pub, err := nats.NewPublisher(cfg.natsURL)
|
||||
pub, err := brokers.NewPublisher(cfg.brokerURL)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to connect to message broker: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer pub.Close()
|
||||
@ -163,11 +163,11 @@ func loadConfig() config {
|
||||
return config{
|
||||
httpPort: mainflux.Env(envHTTPPort, defHTTPPort),
|
||||
loraMsgURL: mainflux.Env(envLoraMsgURL, defLoraMsgURL),
|
||||
brokerURL: mainflux.Env(envBrokerURL, defBrokerURL),
|
||||
loraMsgTopic: mainflux.Env(envLoraMsgTopic, defLoraMsgTopic),
|
||||
loraMsgUser: mainflux.Env(envLoraMsgUser, defLoraMsgUser),
|
||||
loraMsgPass: mainflux.Env(envLoraMsgPass, defLoraMsgPass),
|
||||
loraMsgTimeout: mqttTimeout,
|
||||
natsURL: mainflux.Env(envNatsURL, defNatsURL),
|
||||
logLevel: mainflux.Env(envLogLevel, defLogLevel),
|
||||
esURL: mainflux.Env(envESURL, defESURL),
|
||||
esPass: mainflux.Env(envESPass, defESPass),
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"github.com/mainflux/mainflux/consumers/writers/mongodb"
|
||||
"github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/brokers"
|
||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
@ -30,14 +30,14 @@ const (
|
||||
stopWaitTime = 5 * time.Second
|
||||
|
||||
defLogLevel = "error"
|
||||
defNatsURL = "nats://localhost:4222"
|
||||
defBrokerURL = "nats://localhost:4222"
|
||||
defPort = "8180"
|
||||
defDB = "mainflux"
|
||||
defDBHost = "localhost"
|
||||
defDBPort = "27017"
|
||||
defConfigPath = "/config.toml"
|
||||
|
||||
envNatsURL = "MF_NATS_URL"
|
||||
envBrokerURL = "MF_BROKER_URL"
|
||||
envLogLevel = "MF_MONGO_WRITER_LOG_LEVEL"
|
||||
envPort = "MF_MONGO_WRITER_PORT"
|
||||
envDB = "MF_MONGO_WRITER_DB"
|
||||
@ -47,7 +47,7 @@ const (
|
||||
)
|
||||
|
||||
type config struct {
|
||||
natsURL string
|
||||
brokerURL string
|
||||
logLevel string
|
||||
port string
|
||||
dbName string
|
||||
@ -66,9 +66,9 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
pubSub, err := nats.NewPubSub(cfg.natsURL, "", logger)
|
||||
pubSub, err := brokers.NewPubSub(cfg.brokerURL, "", logger)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to connect to message broker: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer pubSub.Close()
|
||||
@ -112,7 +112,7 @@ func main() {
|
||||
|
||||
func loadConfigs() config {
|
||||
return config{
|
||||
natsURL: mainflux.Env(envNatsURL, defNatsURL),
|
||||
brokerURL: mainflux.Env(envBrokerURL, defBrokerURL),
|
||||
logLevel: mainflux.Env(envLogLevel, defLogLevel),
|
||||
port: mainflux.Env(envPort, defPort),
|
||||
dbName: mainflux.Env(envDB, defDB),
|
||||
|
102
cmd/mqtt/main.go
102
cmd/mqtt/main.go
@ -20,8 +20,8 @@ import (
|
||||
"github.com/mainflux/mainflux/pkg/auth"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/brokers"
|
||||
mqttpub "github.com/mainflux/mainflux/pkg/messaging/mqtt"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
thingsapi "github.com/mainflux/mainflux/things/api/auth/grpc"
|
||||
mp "github.com/mainflux/mproxy/pkg/mqtt"
|
||||
"github.com/mainflux/mproxy/pkg/session"
|
||||
@ -35,62 +35,54 @@ import (
|
||||
|
||||
const (
|
||||
svcName = "mqtt"
|
||||
// Logging
|
||||
defLogLevel = "error"
|
||||
envLogLevel = "MF_MQTT_ADAPTER_LOG_LEVEL"
|
||||
// MQTT
|
||||
|
||||
defLogLevel = "error"
|
||||
defMQTTPort = "1883"
|
||||
defMQTTTargetHost = "0.0.0.0"
|
||||
defMQTTTargetPort = "1883"
|
||||
defMQTTForwarderTimeout = "30s" // 30 seconds
|
||||
defMQTTTargetHealthCheck = ""
|
||||
defHTTPPort = "8080"
|
||||
defHTTPTargetHost = "localhost"
|
||||
defHTTPTargetPort = "8080"
|
||||
defHTTPTargetPath = "/mqtt"
|
||||
defThingsAuthURL = "localhost:8183"
|
||||
defThingsAuthTimeout = "1s"
|
||||
defBrokerURL = "nats://localhost:4222"
|
||||
defJaegerURL = ""
|
||||
defClientTLS = "false"
|
||||
defCACerts = ""
|
||||
defInstance = ""
|
||||
defESURL = "localhost:6379"
|
||||
defESPass = ""
|
||||
defESDB = "0"
|
||||
defAuthcacheURL = "localhost:6379"
|
||||
defAuthCachePass = ""
|
||||
defAuthCacheDB = "0"
|
||||
|
||||
envLogLevel = "MF_MQTT_ADAPTER_LOG_LEVEL"
|
||||
envMQTTPort = "MF_MQTT_ADAPTER_MQTT_PORT"
|
||||
envMQTTTargetHost = "MF_MQTT_ADAPTER_MQTT_TARGET_HOST"
|
||||
envMQTTTargetPort = "MF_MQTT_ADAPTER_MQTT_TARGET_PORT"
|
||||
envMQTTTargetHealthCheck = "MF_MQTT_ADAPTER_MQTT_TARGET_HEALTH_CHECK"
|
||||
envMQTTForwarderTimeout = "MF_MQTT_ADAPTER_FORWARDER_TIMEOUT"
|
||||
// HTTP
|
||||
defHTTPPort = "8080"
|
||||
defHTTPTargetHost = "localhost"
|
||||
defHTTPTargetPort = "8080"
|
||||
defHTTPTargetPath = "/mqtt"
|
||||
envHTTPPort = "MF_MQTT_ADAPTER_WS_PORT"
|
||||
envHTTPTargetHost = "MF_MQTT_ADAPTER_WS_TARGET_HOST"
|
||||
envHTTPTargetPort = "MF_MQTT_ADAPTER_WS_TARGET_PORT"
|
||||
envHTTPTargetPath = "MF_MQTT_ADAPTER_WS_TARGET_PATH"
|
||||
// Things
|
||||
defThingsAuthURL = "localhost:8183"
|
||||
defThingsAuthTimeout = "1s"
|
||||
envThingsAuthURL = "MF_THINGS_AUTH_GRPC_URL"
|
||||
envThingsAuthTimeout = "MF_THINGS_AUTH_GRPC_TIMEOUT"
|
||||
// Nats
|
||||
defNatsURL = "nats://localhost:4222"
|
||||
envNatsURL = "MF_NATS_URL"
|
||||
// Jaeger
|
||||
defJaegerURL = ""
|
||||
envJaegerURL = "MF_JAEGER_URL"
|
||||
// TLS
|
||||
defClientTLS = "false"
|
||||
defCACerts = ""
|
||||
envClientTLS = "MF_MQTT_ADAPTER_CLIENT_TLS"
|
||||
envCACerts = "MF_MQTT_ADAPTER_CA_CERTS"
|
||||
// Instance
|
||||
envInstance = "MF_MQTT_ADAPTER_INSTANCE"
|
||||
defInstance = ""
|
||||
// ES
|
||||
envESURL = "MF_MQTT_ADAPTER_ES_URL"
|
||||
envESPass = "MF_MQTT_ADAPTER_ES_PASS"
|
||||
envESDB = "MF_MQTT_ADAPTER_ES_DB"
|
||||
defESURL = "localhost:6379"
|
||||
defESPass = ""
|
||||
defESDB = "0"
|
||||
// Auth cache
|
||||
envAuthCacheURL = "MF_AUTH_CACHE_URL"
|
||||
envAuthCachePass = "MF_AUTH_CACHE_PASS"
|
||||
envAuthCacheDB = "MF_AUTH_CACHE_DB"
|
||||
defAuthcacheURL = "localhost:6379"
|
||||
defAuthCachePass = ""
|
||||
defAuthCacheDB = "0"
|
||||
envHTTPPort = "MF_MQTT_ADAPTER_WS_PORT"
|
||||
envHTTPTargetHost = "MF_MQTT_ADAPTER_WS_TARGET_HOST"
|
||||
envHTTPTargetPort = "MF_MQTT_ADAPTER_WS_TARGET_PORT"
|
||||
envHTTPTargetPath = "MF_MQTT_ADAPTER_WS_TARGET_PATH"
|
||||
envThingsAuthURL = "MF_THINGS_AUTH_GRPC_URL"
|
||||
envThingsAuthTimeout = "MF_THINGS_AUTH_GRPC_TIMEOUT"
|
||||
envBrokerURL = "MF_BROKER_URL"
|
||||
envJaegerURL = "MF_JAEGER_URL"
|
||||
envClientTLS = "MF_MQTT_ADAPTER_CLIENT_TLS"
|
||||
envCACerts = "MF_MQTT_ADAPTER_CA_CERTS"
|
||||
envInstance = "MF_MQTT_ADAPTER_INSTANCE"
|
||||
envESURL = "MF_MQTT_ADAPTER_ES_URL"
|
||||
envESPass = "MF_MQTT_ADAPTER_ES_PASS"
|
||||
envESDB = "MF_MQTT_ADAPTER_ES_DB"
|
||||
envAuthCacheURL = "MF_AUTH_CACHE_URL"
|
||||
envAuthCachePass = "MF_AUTH_CACHE_PASS"
|
||||
envAuthCacheDB = "MF_AUTH_CACHE_DB"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
@ -108,7 +100,7 @@ type config struct {
|
||||
thingsURL string
|
||||
thingsAuthURL string
|
||||
thingsAuthTimeout time.Duration
|
||||
natsURL string
|
||||
brokerURL string
|
||||
clientTLS bool
|
||||
caCerts string
|
||||
instance string
|
||||
@ -148,9 +140,9 @@ func main() {
|
||||
ec := connectToRedis(cfg.esURL, cfg.esPass, cfg.esDB, logger)
|
||||
defer ec.Close()
|
||||
|
||||
nps, err := nats.NewPubSub(cfg.natsURL, "mqtt", logger)
|
||||
nps, err := brokers.NewPubSub(cfg.brokerURL, "mqtt", logger)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to connect to message broker: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer nps.Close()
|
||||
@ -161,15 +153,15 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fwd := mqtt.NewForwarder(nats.SubjectAllChannels, logger)
|
||||
fwd := mqtt.NewForwarder(brokers.SubjectAllChannels, logger)
|
||||
if err := fwd.Forward(svcName, nps, mpub); err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to forward NATS messages: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to forward message broker messages: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
np, err := nats.NewPublisher(cfg.natsURL)
|
||||
np, err := brokers.NewPublisher(cfg.brokerURL)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to connect to message broker: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer np.Close()
|
||||
@ -241,7 +233,7 @@ func loadConfig() config {
|
||||
thingsAuthURL: mainflux.Env(envThingsAuthURL, defThingsAuthURL),
|
||||
thingsAuthTimeout: authTimeout,
|
||||
thingsURL: mainflux.Env(envThingsAuthURL, defThingsAuthURL),
|
||||
natsURL: mainflux.Env(envNatsURL, defNatsURL),
|
||||
brokerURL: mainflux.Env(envBrokerURL, defBrokerURL),
|
||||
logLevel: mainflux.Env(envLogLevel, defLogLevel),
|
||||
clientTLS: tls,
|
||||
caCerts: mainflux.Env(envCACerts, defCACerts),
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"github.com/mainflux/mainflux/opcua/gopcua"
|
||||
"github.com/mainflux/mainflux/opcua/redis"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/brokers"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
|
||||
@ -38,7 +38,7 @@ const (
|
||||
defOPCMode = ""
|
||||
defOPCCertFile = ""
|
||||
defOPCKeyFile = ""
|
||||
defNatsURL = "nats://localhost:4222"
|
||||
defBrokerURL = "nats://localhost:4222"
|
||||
defESURL = "localhost:6379"
|
||||
defESPass = ""
|
||||
defESDB = "0"
|
||||
@ -54,7 +54,7 @@ const (
|
||||
envOPCMode = "MF_OPCUA_ADAPTER_MODE"
|
||||
envOPCCertFile = "MF_OPCUA_ADAPTER_CERT_FILE"
|
||||
envOPCKeyFile = "MF_OPCUA_ADAPTER_KEY_FILE"
|
||||
envNatsURL = "MF_NATS_URL"
|
||||
envBrokerURL = "MF_BROKER_URL"
|
||||
envESURL = "MF_THINGS_ES_URL"
|
||||
envESPass = "MF_THINGS_ES_PASS"
|
||||
envESDB = "MF_THINGS_ES_DB"
|
||||
@ -71,7 +71,7 @@ const (
|
||||
type config struct {
|
||||
httpPort string
|
||||
opcuaConfig opcua.Config
|
||||
natsURL string
|
||||
brokerURL string
|
||||
logLevel string
|
||||
esURL string
|
||||
esPass string
|
||||
@ -102,9 +102,9 @@ func main() {
|
||||
esConn := connectToRedis(cfg.esURL, cfg.esPass, cfg.esDB, logger)
|
||||
defer esConn.Close()
|
||||
|
||||
pubSub, err := nats.NewPubSub(cfg.natsURL, "", logger)
|
||||
pubSub, err := brokers.NewPubSub(cfg.brokerURL, "", logger)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to connect to message broker: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer pubSub.Close()
|
||||
@ -162,7 +162,7 @@ func loadConfig() config {
|
||||
return config{
|
||||
httpPort: mainflux.Env(envHTTPPort, defHTTPPort),
|
||||
opcuaConfig: oc,
|
||||
natsURL: mainflux.Env(envNatsURL, defNatsURL),
|
||||
brokerURL: mainflux.Env(envBrokerURL, defBrokerURL),
|
||||
logLevel: mainflux.Env(envLogLevel, defLogLevel),
|
||||
esURL: mainflux.Env(envESURL, defESURL),
|
||||
esPass: mainflux.Env(envESPass, defESPass),
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"github.com/mainflux/mainflux/consumers/writers/postgres"
|
||||
"github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/brokers"
|
||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
@ -29,7 +29,7 @@ const (
|
||||
stopWaitTime = 5 * time.Second
|
||||
|
||||
defLogLevel = "error"
|
||||
defNatsURL = "nats://localhost:4222"
|
||||
defBrokerURL = "nats://localhost:4222"
|
||||
defPort = "8180"
|
||||
defDBHost = "localhost"
|
||||
defDBPort = "5432"
|
||||
@ -42,7 +42,7 @@ const (
|
||||
defDBSSLRootCert = ""
|
||||
defConfigPath = "/config.toml"
|
||||
|
||||
envNatsURL = "MF_NATS_URL"
|
||||
envBrokerURL = "MF_BROKER_URL"
|
||||
envLogLevel = "MF_POSTGRES_WRITER_LOG_LEVEL"
|
||||
envPort = "MF_POSTGRES_WRITER_PORT"
|
||||
envDBHost = "MF_POSTGRES_WRITER_DB_HOST"
|
||||
@ -58,7 +58,7 @@ const (
|
||||
)
|
||||
|
||||
type config struct {
|
||||
natsURL string
|
||||
brokerURL string
|
||||
logLevel string
|
||||
port string
|
||||
configPath string
|
||||
@ -75,9 +75,9 @@ func main() {
|
||||
log.Fatalf(err.Error())
|
||||
}
|
||||
|
||||
pubSub, err := nats.NewPubSub(cfg.natsURL, "", logger)
|
||||
pubSub, err := brokers.NewPubSub(cfg.brokerURL, "", logger)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to connect to message broker: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer pubSub.Close()
|
||||
@ -123,7 +123,7 @@ func loadConfig() config {
|
||||
}
|
||||
|
||||
return config{
|
||||
natsURL: mainflux.Env(envNatsURL, defNatsURL),
|
||||
brokerURL: mainflux.Env(envBrokerURL, defBrokerURL),
|
||||
logLevel: mainflux.Env(envLogLevel, defLogLevel),
|
||||
port: mainflux.Env(envPort, defPort),
|
||||
configPath: mainflux.Env(envConfigPath, defConfigPath),
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
"github.com/mainflux/mainflux/consumers/notifiers/tracing"
|
||||
"github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/brokers"
|
||||
"github.com/mainflux/mainflux/pkg/ulid"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
||||
@ -56,7 +56,7 @@ const (
|
||||
defServerKey = ""
|
||||
defFrom = ""
|
||||
defJaegerURL = ""
|
||||
defNatsURL = "nats://localhost:4222"
|
||||
defBrokerURL = "nats://localhost:4222"
|
||||
|
||||
defSmppAddress = ""
|
||||
defSmppUsername = ""
|
||||
@ -88,7 +88,7 @@ const (
|
||||
envServerKey = "MF_SMPP_NOTIFIER_SERVER_KEY"
|
||||
envFrom = "MF_SMPP_NOTIFIER_SOURCE_ADDR"
|
||||
envJaegerURL = "MF_JAEGER_URL"
|
||||
envNatsURL = "MF_NATS_URL"
|
||||
envBrokerURL = "MF_BROKER_URL"
|
||||
|
||||
envSmppAddress = "MF_SMPP_ADDRESS"
|
||||
envSmppUsername = "MF_SMPP_USERNAME"
|
||||
@ -106,7 +106,7 @@ const (
|
||||
)
|
||||
|
||||
type config struct {
|
||||
natsURL string
|
||||
brokerURL string
|
||||
configPath string
|
||||
logLevel string
|
||||
dbConfig postgres.Config
|
||||
@ -135,9 +135,9 @@ func main() {
|
||||
db := connectToDB(cfg.dbConfig, logger)
|
||||
defer db.Close()
|
||||
|
||||
pubSub, err := nats.NewPubSub(cfg.natsURL, "", logger)
|
||||
pubSub, err := brokers.NewPubSub(cfg.brokerURL, "", logger)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to connect to message broker: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer pubSub.Close()
|
||||
@ -233,7 +233,7 @@ func loadConfig() config {
|
||||
|
||||
return config{
|
||||
logLevel: mainflux.Env(envLogLevel, defLogLevel),
|
||||
natsURL: mainflux.Env(envNatsURL, defNatsURL),
|
||||
brokerURL: mainflux.Env(envBrokerURL, defBrokerURL),
|
||||
configPath: mainflux.Env(envConfigPath, defConfigPath),
|
||||
dbConfig: dbConfig,
|
||||
smppConf: smppConf,
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
"github.com/mainflux/mainflux/internal/email"
|
||||
"github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/brokers"
|
||||
"github.com/mainflux/mainflux/pkg/ulid"
|
||||
opentracing "github.com/opentracing/opentracing-go"
|
||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
||||
@ -56,7 +56,7 @@ const (
|
||||
defServerKey = ""
|
||||
defFrom = ""
|
||||
defJaegerURL = ""
|
||||
defNatsURL = "nats://localhost:4222"
|
||||
defBrokerURL = "nats://localhost:4222"
|
||||
|
||||
defEmailHost = "localhost"
|
||||
defEmailPort = "25"
|
||||
@ -87,7 +87,7 @@ const (
|
||||
envServerKey = "MF_SMTP_NOTIFIER_SERVER_KEY"
|
||||
envFrom = "MF_SMTP_NOTIFIER_FROM_ADDR"
|
||||
envJaegerURL = "MF_JAEGER_URL"
|
||||
envNatsURL = "MF_NATS_URL"
|
||||
envBrokerURL = "MF_BROKER_URL"
|
||||
|
||||
envEmailHost = "MF_EMAIL_HOST"
|
||||
envEmailPort = "MF_EMAIL_PORT"
|
||||
@ -104,7 +104,7 @@ const (
|
||||
)
|
||||
|
||||
type config struct {
|
||||
natsURL string
|
||||
brokerURL string
|
||||
configPath string
|
||||
logLevel string
|
||||
dbConfig postgres.Config
|
||||
@ -133,9 +133,9 @@ func main() {
|
||||
db := connectToDB(cfg.dbConfig, logger)
|
||||
defer db.Close()
|
||||
|
||||
pubSub, err := nats.NewPubSub(cfg.natsURL, "", logger)
|
||||
pubSub, err := brokers.NewPubSub(cfg.brokerURL, "", logger)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to connect to message broker: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer pubSub.Close()
|
||||
@ -213,7 +213,7 @@ func loadConfig() config {
|
||||
|
||||
return config{
|
||||
logLevel: mainflux.Env(envLogLevel, defLogLevel),
|
||||
natsURL: mainflux.Env(envNatsURL, defNatsURL),
|
||||
brokerURL: mainflux.Env(envBrokerURL, defBrokerURL),
|
||||
configPath: mainflux.Env(envConfigPath, defConfigPath),
|
||||
dbConfig: dbConfig,
|
||||
emailConf: emailConf,
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"github.com/mainflux/mainflux/consumers/writers/timescale"
|
||||
"github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/brokers"
|
||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
@ -29,7 +29,7 @@ const (
|
||||
stopWaitTime = 5 * time.Second
|
||||
|
||||
defLogLevel = "error"
|
||||
defNatsURL = "nats://localhost:4222"
|
||||
defBrokerURL = "nats://localhost:4222"
|
||||
defPort = "8180"
|
||||
defDBHost = "localhost"
|
||||
defDBPort = "5432"
|
||||
@ -42,7 +42,7 @@ const (
|
||||
defDBSSLRootCert = ""
|
||||
defConfigPath = "/config.toml"
|
||||
|
||||
envNatsURL = "MF_NATS_URL"
|
||||
envBrokerURL = "MF_BROKER_URL"
|
||||
envLogLevel = "MF_TIMESCALE_WRITER_LOG_LEVEL"
|
||||
envPort = "MF_TIMESCALE_WRITER_PORT"
|
||||
envDBHost = "MF_TIMESCALE_WRITER_DB_HOST"
|
||||
@ -58,7 +58,7 @@ const (
|
||||
)
|
||||
|
||||
type config struct {
|
||||
natsURL string
|
||||
brokerURL string
|
||||
logLevel string
|
||||
port string
|
||||
configPath string
|
||||
@ -75,9 +75,9 @@ func main() {
|
||||
log.Fatalf(err.Error())
|
||||
}
|
||||
|
||||
pubSub, err := nats.NewPubSub(cfg.natsURL, "", logger)
|
||||
pubSub, err := brokers.NewPubSub(cfg.brokerURL, "", logger)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to connect to message broker: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer pubSub.Close()
|
||||
@ -122,7 +122,7 @@ func loadConfig() config {
|
||||
}
|
||||
|
||||
return config{
|
||||
natsURL: mainflux.Env(envNatsURL, defNatsURL),
|
||||
brokerURL: mainflux.Env(envBrokerURL, defBrokerURL),
|
||||
logLevel: mainflux.Env(envLogLevel, defLogLevel),
|
||||
port: mainflux.Env(envPort, defPort),
|
||||
configPath: mainflux.Env(envConfigPath, defConfigPath),
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/brokers"
|
||||
"github.com/mainflux/mainflux/pkg/uuid"
|
||||
localusers "github.com/mainflux/mainflux/things/standalone"
|
||||
"github.com/mainflux/mainflux/twins"
|
||||
@ -59,7 +59,7 @@ const (
|
||||
defClientTLS = "false"
|
||||
defCACerts = ""
|
||||
defChannelID = ""
|
||||
defNatsURL = "nats://localhost:4222"
|
||||
defBrokerURL = "nats://localhost:4222"
|
||||
defAuthURL = "localhost:8181"
|
||||
defAuthTimeout = "1s"
|
||||
|
||||
@ -79,7 +79,7 @@ const (
|
||||
envClientTLS = "MF_TWINS_CLIENT_TLS"
|
||||
envCACerts = "MF_TWINS_CA_CERTS"
|
||||
envChannelID = "MF_TWINS_CHANNEL_ID"
|
||||
envNatsURL = "MF_NATS_URL"
|
||||
envBrokerURL = "MF_BROKER_URL"
|
||||
envAuthURL = "MF_AUTH_GRPC_URL"
|
||||
envAuthTimeout = "MF_AUTH_GRPC_TIMEOUT"
|
||||
)
|
||||
@ -99,7 +99,7 @@ type config struct {
|
||||
clientTLS bool
|
||||
caCerts string
|
||||
channelID string
|
||||
natsURL string
|
||||
brokerURL string
|
||||
|
||||
authURL string
|
||||
authTimeout time.Duration
|
||||
@ -131,9 +131,9 @@ func main() {
|
||||
defer authCloser.Close()
|
||||
auth, _ := createAuthClient(cfg, authTracer, logger)
|
||||
|
||||
pubSub, err := nats.NewPubSub(cfg.natsURL, queue, logger)
|
||||
pubSub, err := brokers.NewPubSub(cfg.brokerURL, queue, logger)
|
||||
if err != nil {
|
||||
logger.Error(fmt.Sprintf("Failed to connect to NATS: %s", err))
|
||||
logger.Error(fmt.Sprintf("Failed to connect to message broker: %s", err))
|
||||
os.Exit(1)
|
||||
}
|
||||
defer pubSub.Close()
|
||||
@ -192,7 +192,7 @@ func loadConfig() config {
|
||||
clientTLS: tls,
|
||||
caCerts: mainflux.Env(envCACerts, defCACerts),
|
||||
channelID: mainflux.Env(envChannelID, defChannelID),
|
||||
natsURL: mainflux.Env(envNatsURL, defNatsURL),
|
||||
brokerURL: mainflux.Env(envBrokerURL, defBrokerURL),
|
||||
authURL: mainflux.Env(envAuthURL, defAuthURL),
|
||||
authTimeout: authTimeout,
|
||||
}
|
||||
@ -298,12 +298,11 @@ func newService(id string, ps messaging.PubSub, chanID string, users mainflux.Au
|
||||
Help: "Total duration of requests in microseconds.",
|
||||
}, []string{"method"}),
|
||||
)
|
||||
err := ps.Subscribe(id, nats.SubjectAllChannels, handle(logger, chanID, svc))
|
||||
err := ps.Subscribe(id, brokers.SubjectAllChannels, handle(logger, chanID, svc))
|
||||
if err != nil {
|
||||
logger.Error(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ default values.
|
||||
| Variable | Description | Default |
|
||||
|--------------------------------|--------------------------------------------------------|-----------------------|
|
||||
| MF_COAP_ADAPTER_PORT | Service listening port | 5683 |
|
||||
| MF_NATS_URL | NATS instance URL | nats://localhost:4222 |
|
||||
| MF_BROKER_URL | Message broker instance URL | nats://localhost:4222 |
|
||||
| MF_COAP_ADAPTER_LOG_LEVEL | Service log level | error |
|
||||
| MF_COAP_ADAPTER_CLIENT_TLS | Flag that indicates if TLS should be turned on | false |
|
||||
| MF_COAP_ADAPTER_CA_CERTS | Path to trusted CAs in PEM format | |
|
||||
@ -26,7 +26,7 @@ default values.
|
||||
The service itself is distributed as Docker container. Check the [`coap-adapter`](https://github.com/mainflux/mainflux/blob/master/docker/docker-compose.yml#L273-L291) service section in
|
||||
docker-compose to see how service is deployed.
|
||||
|
||||
Running this service outside of container requires working instance of the NATS service.
|
||||
Running this service outside of container requires working instance of the message broker service.
|
||||
To start the service outside of the container, execute the following shell script:
|
||||
|
||||
```bash
|
||||
@ -42,7 +42,7 @@ make coap
|
||||
make install
|
||||
|
||||
# set the environment variables and run the service
|
||||
MF_NATS_URL=[NATS instance URL] \
|
||||
MF_BROKER_URL=[Message broker instance URL] \
|
||||
MF_COAP_ADAPTER_PORT=[Service HTTP port] \
|
||||
MF_COAP_ADAPTER_LOG_LEVEL=[Service log level] \
|
||||
MF_COAP_ADAPTER_CLIENT_TLS=[Flag that indicates if TLS should be turned on] \
|
||||
|
@ -12,7 +12,6 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
|
||||
"github.com/mainflux/mainflux"
|
||||
"github.com/mainflux/mainflux/pkg/messaging"
|
||||
@ -41,12 +40,12 @@ var _ Service = (*adapterService)(nil)
|
||||
// Observers is a map of maps,
|
||||
type adapterService struct {
|
||||
auth mainflux.ThingsServiceClient
|
||||
pubsub nats.PubSub
|
||||
pubsub messaging.PubSub
|
||||
obsLock sync.Mutex
|
||||
}
|
||||
|
||||
// New instantiates the CoAP adapter implementation.
|
||||
func New(auth mainflux.ThingsServiceClient, pubsub nats.PubSub) Service {
|
||||
func New(auth mainflux.ThingsServiceClient, pubsub messaging.PubSub) Service {
|
||||
as := &adapterService{
|
||||
auth: auth,
|
||||
pubsub: pubsub,
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
"github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging"
|
||||
pubsub "github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/brokers"
|
||||
"github.com/mainflux/mainflux/pkg/transformers"
|
||||
"github.com/mainflux/mainflux/pkg/transformers/json"
|
||||
"github.com/mainflux/mainflux/pkg/transformers/senml"
|
||||
@ -30,7 +30,7 @@ var (
|
||||
errParseConfFile = errors.New("unable to parse configuration file")
|
||||
)
|
||||
|
||||
// Start method starts consuming messages received from NATS.
|
||||
// Start method starts consuming messages received from Message broker.
|
||||
// This method transforms messages to SenML format before
|
||||
// using MessageRepository to store them.
|
||||
func Start(id string, sub messaging.Subscriber, consumer Consumer, configPath string, logger logger.Logger) error {
|
||||
@ -92,7 +92,7 @@ type config struct {
|
||||
func loadConfig(configPath string) (config, error) {
|
||||
cfg := config{
|
||||
SubscriberCfg: subscriberConfig{
|
||||
Subjects: []string{pubsub.SubjectAllChannels},
|
||||
Subjects: []string{brokers.SubjectAllChannels},
|
||||
},
|
||||
TransformerCfg: transformerConfig{
|
||||
Format: defFormat,
|
||||
|
@ -25,7 +25,7 @@ default values.
|
||||
| MF_SMPP_NOTIFIER_SERVER_CERT | Path to server cert in pem format | |
|
||||
| MF_SMPP_NOTIFIER_SERVER_KEY | Path to server key in pem format | |
|
||||
| MF_JAEGER_URL | Jaeger server URL | localhost:6831 |
|
||||
| MF_NATS_URL | NATS broker URL | nats://127.0.0.1:4222 |
|
||||
| MF_BROKER_URL | Message broker URL | nats://127.0.0.1:4222 |
|
||||
| MF_SMPP_ADDRESS | SMPP address [host:port] | |
|
||||
| MF_SMPP_USERNAME | SMPP Username | |
|
||||
| MF_SMPP_PASSWORD | SMPP Password | |
|
||||
|
@ -16,7 +16,7 @@ default values.
|
||||
| MF_SMTP_NOTIFIER_DB_USER | Database user | mainflux |
|
||||
| MF_SMTP_NOTIFIER_DB_PASS | Database password | mainflux |
|
||||
| MF_SMTP_NOTIFIER_DB | Name of the database used by the service | subscriptions |
|
||||
| MF_SMTP_NOTIFIER_CONFIG_PATH | Path to the config file with NATS subjects configuration | disable |
|
||||
| MF_SMTP_NOTIFIER_CONFIG_PATH | Path to the config file with message broker subjects configuration | disable |
|
||||
| MF_SMTP_NOTIFIER_DB_SSL_MODE | Database connection SSL mode (disable, require, verify-ca, verify-full) | |
|
||||
| MF_SMTP_NOTIFIER_DB_SSL_CERT | Path to the PEM encoded cert file | |
|
||||
| MF_SMTP_NOTIFIER_DB_SSL_KEY | Path to the PEM encoded certificate key | |
|
||||
@ -25,7 +25,7 @@ default values.
|
||||
| MF_SMTP_NOTIFIER_SERVER_CERT | Path to server cert in pem format | |
|
||||
| MF_SMTP_NOTIFIER_SERVER_KEY | Path to server key in pem format | |
|
||||
| MF_JAEGER_URL | Jaeger server URL | localhost:6831 |
|
||||
| MF_NATS_URL | NATS broker URL | nats://127.0.0.1:4222 |
|
||||
| MF_BROKER_URL | Message broker URL | nats://127.0.0.1:4222 |
|
||||
| MF_EMAIL_HOST | Mail server host | localhost |
|
||||
| MF_EMAIL_PORT | Mail server port | 25 |
|
||||
| MF_EMAIL_USERNAME | Mail server username | |
|
||||
|
@ -10,7 +10,7 @@ default values.
|
||||
|
||||
| Variable | Description | Default |
|
||||
| -------------------------------- | ----------------------------------------------------------------------- | --------------------- |
|
||||
| MF_NATS_URL | NATS instance URL | nats://localhost:4222 |
|
||||
| MF_BROKER_URL | Message broker instance URL | nats://localhost:4222 |
|
||||
| MF_CASSANDRA_WRITER_LOG_LEVEL | Log level for Cassandra writer (debug, info, warn, error) | error |
|
||||
| MF_CASSANDRA_WRITER_PORT | Service HTTP port | 8180 |
|
||||
| MF_CASSANDRA_WRITER_DB_CLUSTER | Cassandra cluster comma separated addresses | 127.0.0.1 |
|
||||
@ -38,7 +38,7 @@ make cassandra-writer
|
||||
make install
|
||||
|
||||
# Set the environment variables and run the service
|
||||
MF_NATS_URL=[NATS instance URL] \
|
||||
MF_BROKER_URL=[NATS instance URL] \
|
||||
MF_CASSANDRA_WRITER_LOG_LEVEL=[Cassandra writer log level] \
|
||||
MF_CASSANDRA_WRITER_PORT=[Service HTTP port] \
|
||||
MF_CASSANDRA_WRITER_DB_CLUSTER=[Cassandra cluster comma separated addresses] \
|
||||
|
@ -8,17 +8,17 @@ The service is configured using the environment variables presented in the
|
||||
following table. Note that any unset variables will be replaced with their
|
||||
default values.
|
||||
|
||||
| Variable | Description | Default |
|
||||
| ----------------------------- | ----------------------------------------------------------------------- | ---------------------- |
|
||||
| MF_NATS_URL | NATS instance URL | nats://localhost:4222 |
|
||||
| MF_INFLUX_WRITER_LOG_LEVEL | Log level for InfluxDB writer (debug, info, warn, error) | error |
|
||||
| MF_INFLUX_WRITER_PORT | Service HTTP port | 8180 |
|
||||
| MF_INFLUXDB_HOST | InfluxDB host | localhost |
|
||||
| MF_INFLUXDB_PORT | Default port of InfluxDB database | 8086 |
|
||||
| MF_INFLUXDB_ADMIN_USER | Default user of InfluxDB database | mainflux |
|
||||
| MF_INFLUXDB_ADMIN_PASSWORD | Default password of InfluxDB user | mainflux |
|
||||
| MF_INFLUXDB_DB | InfluxDB database name | mainflux |
|
||||
| MF_INFLUX_WRITER_CONFIG_PATH | Config file path with NATS subjects list, payload type and content-type | /configs.toml |
|
||||
| Variable | Description | Default |
|
||||
| ----------------------------- | --------------------------------------------------------------------------------- | ---------------------- |
|
||||
| MF_BROKER_URL | Message broker instance URL | nats://localhost:4222 |
|
||||
| MF_INFLUX_WRITER_LOG_LEVEL | Log level for InfluxDB writer (debug, info, warn, error) | error |
|
||||
| MF_INFLUX_WRITER_PORT | Service HTTP port | 8180 |
|
||||
| MF_INFLUX_WRITER_DB_HOST | InfluxDB host | localhost |
|
||||
| MF_INFLUXDB_PORT | Default port of InfluxDB database | 8086 |
|
||||
| MF_INFLUXDB_ADMIN_USER | Default user of InfluxDB database | mainflux |
|
||||
| MF_INFLUXDB_ADMIN_PASSWORD | Default password of InfluxDB user | mainflux |
|
||||
| MF_INFLUXDB_DB | InfluxDB database name | mainflux |
|
||||
| MF_INFLUX_WRITER_CONFIG_PATH | Config file path with message broker subjects list, payload type and content-type | /configs.toml |
|
||||
|
||||
## Deployment
|
||||
|
||||
@ -39,7 +39,7 @@ make influxdb
|
||||
make install
|
||||
|
||||
# Set the environment variables and run the service
|
||||
MF_NATS_URL=[NATS instance URL] \
|
||||
MF_BROKER_URL=[Message broker instance URL] \
|
||||
MF_INFLUX_WRITER_LOG_LEVEL=[Influx writer log level] \
|
||||
MF_INFLUX_WRITER_PORT=[Service HTTP port] \
|
||||
MF_INFLUXDB_DB=[InfluxDB database name] \
|
||||
@ -47,7 +47,7 @@ MF_INFLUXDB_HOST=[InfluxDB database host] \
|
||||
MF_INFLUXDB_PORT=[InfluxDB database port] \
|
||||
MF_INFLUXDB_ADMIN_USER=[InfluxDB admin user] \
|
||||
MF_INFLUXDB_ADMIN_PASSWORD=[InfluxDB admin password] \
|
||||
MF_INFLUX_WRITER_CONFIG_PATH=[Config file path with NATS subjects list, payload type and content-type] \
|
||||
MF_INFLUX_WRITER_CONFIG_PATH=[Config file path with Message broker subjects list, payload type and content-type] \
|
||||
$GOBIN/mainflux-influxdb
|
||||
```
|
||||
|
||||
|
@ -8,15 +8,15 @@ The service is configured using the environment variables presented in the
|
||||
following table. Note that any unset variables will be replaced with their
|
||||
default values.
|
||||
|
||||
| Variable | Description | Default |
|
||||
| ---------------------------- | ----------------------------------------------------------------------- | ---------------------- |
|
||||
| MF_NATS_URL | NATS instance URL | nats://localhost:4222 |
|
||||
| MF_MONGO_WRITER_LOG_LEVEL | Log level for MongoDB writer | error |
|
||||
| MF_MONGO_WRITER_PORT | Service HTTP port | 8180 |
|
||||
| MF_MONGO_WRITER_DB | Default MongoDB database name | messages |
|
||||
| MF_MONGO_WRITER_DB_HOST | Default MongoDB database host | localhost |
|
||||
| MF_MONGO_WRITER_DB_PORT | Default MongoDB database port | 27017 |
|
||||
| MF_MONGO_WRITER_CONFIG_PATH | Config file path with NATS subjects list, payload type and content-type | /config.toml |
|
||||
| Variable | Description | Default |
|
||||
| ---------------------------- | --------------------------------------------------------------------------------- | ---------------------- |
|
||||
| MF_BROKER_URL | Message broker instance URL | nats://localhost:4222 |
|
||||
| MF_MONGO_WRITER_LOG_LEVEL | Log level for MongoDB writer | error |
|
||||
| MF_MONGO_WRITER_PORT | Service HTTP port | 8180 |
|
||||
| MF_MONGO_WRITER_DB | Default MongoDB database name | messages |
|
||||
| MF_MONGO_WRITER_DB_HOST | Default MongoDB database host | localhost |
|
||||
| MF_MONGO_WRITER_DB_PORT | Default MongoDB database port | 27017 |
|
||||
| MF_MONGO_WRITER_CONFIG_PATH | Config file path with Message broker subjects list, payload type and content-type | /config.toml |
|
||||
|
||||
## Deployment
|
||||
|
||||
@ -37,13 +37,13 @@ make mongodb-writer
|
||||
make install
|
||||
|
||||
# Set the environment variables and run the service
|
||||
MF_NATS_URL=[NATS instance URL] \
|
||||
MF_BROKER_URL=[Message broker instance URL] \
|
||||
MF_MONGO_WRITER_LOG_LEVEL=[MongoDB writer log level] \
|
||||
MF_MONGO_WRITER_PORT=[Service HTTP port] \
|
||||
MF_MONGO_WRITER_DB=[MongoDB database name] \
|
||||
MF_MONGO_WRITER_DB_HOST=[MongoDB database host] \
|
||||
MF_MONGO_WRITER_DB_PORT=[MongoDB database port] \
|
||||
MF_MONGO_WRITER_CONFIG_PATH=[Configuration file path with NATS subjects list] \
|
||||
MF_MONGO_WRITER_CONFIG_PATH=[Configuration file path with Message broker subjects list] \
|
||||
$GOBIN/mainflux-mongodb-writer
|
||||
```
|
||||
|
||||
|
@ -8,21 +8,21 @@ The service is configured using the environment variables presented in the
|
||||
following table. Note that any unset variables will be replaced with their
|
||||
default values.
|
||||
|
||||
| Variable | Description | Default |
|
||||
| ----------------------------------- | ----------------------------------------------------------------------- | ---------------------- |
|
||||
| MF_NATS_URL | NATS instance URL | nats://localhost:4222 |
|
||||
| MF_POSTGRES_WRITER_LOG_LEVEL | Service log level | error |
|
||||
| MF_POSTGRES_WRITER_PORT | Service HTTP port | 9104 |
|
||||
| MF_POSTGRES_WRITER_DB_HOST | Postgres DB host | postgres |
|
||||
| MF_POSTGRES_WRITER_DB_PORT | Postgres DB port | 5432 |
|
||||
| MF_POSTGRES_WRITER_DB_USER | Postgres user | mainflux |
|
||||
| MF_POSTGRES_WRITER_DB_PASS | Postgres password | mainflux |
|
||||
| MF_POSTGRES_WRITER_DB | Postgres database name | messages |
|
||||
| MF_POSTGRES_WRITER_DB_SSL_MODE | Postgres SSL mode | disabled |
|
||||
| MF_POSTGRES_WRITER_DB_SSL_CERT | Postgres SSL certificate path | "" |
|
||||
| MF_POSTGRES_WRITER_DB_SSL_KEY | Postgres SSL key | "" |
|
||||
| MF_POSTGRES_WRITER_DB_SSL_ROOT_CERT | Postgres SSL root certificate path | "" |
|
||||
| MF_POSTGRES_WRITER_CONFIG_PATH | Config file path with NATS subjects list, payload type and content-type | /config.toml |
|
||||
| Variable | Description | Default |
|
||||
| ----------------------------------- | --------------------------------------------------------------------------------- | ---------------------- |
|
||||
| MF_BROKER_URL | Message broker instance URL | nats://localhost:4222 |
|
||||
| MF_POSTGRES_WRITER_LOG_LEVEL | Service log level | error |
|
||||
| MF_POSTGRES_WRITER_PORT | Service HTTP port | 9104 |
|
||||
| MF_POSTGRES_WRITER_DB_HOST | Postgres DB host | postgres |
|
||||
| MF_POSTGRES_WRITER_DB_PORT | Postgres DB port | 5432 |
|
||||
| MF_POSTGRES_WRITER_DB_USER | Postgres user | mainflux |
|
||||
| MF_POSTGRES_WRITER_DB_PASS | Postgres password | mainflux |
|
||||
| MF_POSTGRES_WRITER_DB | Postgres database name | messages |
|
||||
| MF_POSTGRES_WRITER_DB_SSL_MODE | Postgres SSL mode | disabled |
|
||||
| MF_POSTGRES_WRITER_DB_SSL_CERT | Postgres SSL certificate path | "" |
|
||||
| MF_POSTGRES_WRITER_DB_SSL_KEY | Postgres SSL key | "" |
|
||||
| MF_POSTGRES_WRITER_DB_SSL_ROOT_CERT | Postgres SSL root certificate path | "" |
|
||||
| MF_POSTGRES_WRITER_CONFIG_PATH | Config file path with Message broker subjects list, payload type and content-type | /config.toml |
|
||||
|
||||
## Deployment
|
||||
|
||||
@ -43,7 +43,7 @@ make postgres-writer
|
||||
make install
|
||||
|
||||
# Set the environment variables and run the service
|
||||
MF_NATS_URL=[NATS instance URL] \
|
||||
MF_BROKER_URL=[Message broker instance URL] \
|
||||
MF_POSTGRES_WRITER_LOG_LEVEL=[Service log level] \
|
||||
MF_POSTGRES_WRITER_PORT=[Service HTTP port] \
|
||||
MF_POSTGRES_WRITER_DB_HOST=[Postgres host] \
|
||||
@ -55,7 +55,7 @@ MF_POSTGRES_WRITER_DB_SSL_MODE=[Postgres SSL mode] \
|
||||
MF_POSTGRES_WRITER_DB_SSL_CERT=[Postgres SSL cert] \
|
||||
MF_POSTGRES_WRITER_DB_SSL_KEY=[Postgres SSL key] \
|
||||
MF_POSTGRES_WRITER_DB_SSL_ROOT_CERT=[Postgres SSL Root cert] \
|
||||
MF_POSTGRES_WRITER_CONFIG_PATH=[Config file path with NATS subjects list, payload type and content-type] \
|
||||
MF_POSTGRES_WRITER_CONFIG_PATH=[Config file path with Message broker subjects list, payload type and content-type] \
|
||||
$GOBIN/mainflux-postgres-writer
|
||||
```
|
||||
|
||||
|
@ -8,21 +8,21 @@ The service is configured using the environment variables presented in the
|
||||
following table. Note that any unset variables will be replaced with their
|
||||
default values.
|
||||
|
||||
| Variable | Description | Default |
|
||||
| ----------------------------------- | ----------------------------------------------- | ---------------------- |
|
||||
| MF_NATS_URL | NATS instance URL | nats://localhost:4222 |
|
||||
| MF_TIMESCALE_WRITER_LOG_LEVEL | Service log level | error |
|
||||
| MF_TIMESCALE_WRITER_PORT | Service HTTP port | 9104 |
|
||||
| MF_TIMESCALE_WRITER_DB_HOST | Timescale DB host | timescale |
|
||||
| MF_TIMESCALE_WRITER_DB_PORT | Timescale DB port | 5432 |
|
||||
| MF_TIMESCALE_WRITER_DB_USER | Timescale user | mainflux |
|
||||
| MF_TIMESCALE_WRITER_DB_PASS | Timescale password | mainflux |
|
||||
| MF_TIMESCALE_WRITER_DB | Timescale database name | messages |
|
||||
| MF_TIMESCALE_WRITER_DB_SSL_MODE | Timescale SSL mode | disabled |
|
||||
| MF_TIMESCALE_WRITER_DB_SSL_CERT | Timescale SSL certificate path | "" |
|
||||
| MF_TIMESCALE_WRITER_DB_SSL_KEY | Timescale SSL key | "" |
|
||||
| MF_TIMESCALE_WRITER_DB_SSL_ROOT_CERT | Timescale SSL root certificate path | "" |
|
||||
| MF_TIMESCALE_WRITER_CONFIG_PATH | Configuration file path with NATS subjects list | /config.toml |
|
||||
| Variable | Description | Default |
|
||||
| ----------------------------------- | --------------------------------------------------------- | ---------------------- |
|
||||
| MF_BROKER_URL | Message broker instance URL | nats://localhost:4222 |
|
||||
| MF_TIMESCALE_WRITER_LOG_LEVEL | Service log level | error |
|
||||
| MF_TIMESCALE_WRITER_PORT | Service HTTP port | 9104 |
|
||||
| MF_TIMESCALE_WRITER_DB_HOST | Timescale DB host | timescale |
|
||||
| MF_TIMESCALE_WRITER_DB_PORT | Timescale DB port | 5432 |
|
||||
| MF_TIMESCALE_WRITER_DB_USER | Timescale user | mainflux |
|
||||
| MF_TIMESCALE_WRITER_DB_PASS | Timescale password | mainflux |
|
||||
| MF_TIMESCALE_WRITER_DB | Timescale database name | messages |
|
||||
| MF_TIMESCALE_WRITER_DB_SSL_MODE | Timescale SSL mode | disabled |
|
||||
| MF_TIMESCALE_WRITER_DB_SSL_CERT | Timescale SSL certificate path | "" |
|
||||
| MF_TIMESCALE_WRITER_DB_SSL_KEY | Timescale SSL key | "" |
|
||||
| MF_TIMESCALE_WRITER_DB_SSL_ROOT_CERT | Timescale SSL root certificate path | "" |
|
||||
| MF_TIMESCALE_WRITER_CONFIG_PATH | Configuration file path with Message broker subjects list | /config.toml |
|
||||
|
||||
## Deployment
|
||||
|
||||
@ -43,7 +43,7 @@ make timescale-writer
|
||||
make install
|
||||
|
||||
# Set the environment variables and run the service
|
||||
MF_NATS_URL=[NATS instance URL] \
|
||||
MF_BROKER_URL=[Message broker instance URL] \
|
||||
MF_TIMESCALE_WRITER_LOG_LEVEL=[Service log level] \
|
||||
MF_TIMESCALE_WRITER_PORT=[Service HTTP port] \
|
||||
MF_TIMESCALE_WRITER_DB_HOST=[Timescale host] \
|
||||
@ -55,7 +55,7 @@ MF_TIMESCALE_WRITER_DB_SSL_MODE=[Timescale SSL mode] \
|
||||
MF_TIMESCALE_WRITER_DB_SSL_CERT=[Timescale SSL cert] \
|
||||
MF_TIMESCALE_WRITER_DB_SSL_KEY=[Timescale SSL key] \
|
||||
MF_TIMESCALE_WRITER_DB_SSL_ROOT_CERT=[Timescale SSL Root cert] \
|
||||
MF_TIMESCALE_WRITER_CONFIG_PATH=[Configuration file path with NATS subjects list] \
|
||||
MF_TIMESCALE_WRITER_CONFIG_PATH=[Configuration file path with Message broker subjects list] \
|
||||
MF_TIMESCALE_WRITER_TRANSFORMER=[Message transformer type] \
|
||||
$GOBIN/mainflux-timescale-writer
|
||||
```
|
||||
|
17
docker/.env
17
docker/.env
@ -6,8 +6,21 @@ MF_NGINX_SSL_PORT=443
|
||||
MF_NGINX_MQTT_PORT=1883
|
||||
MF_NGINX_MQTTS_PORT=8883
|
||||
|
||||
## NATS
|
||||
MF_NATS_URL=nats://nats:4222
|
||||
# Message Broker
|
||||
MF_BROKER_TYPE=nats
|
||||
|
||||
## Nats
|
||||
MF_NATS_PORT=4222
|
||||
MF_NATS_URL=nats://broker:${MF_NATS_PORT}
|
||||
|
||||
## RabbitMQ
|
||||
MF_RABBITMQ_PORT=5672
|
||||
MF_RABBITMQ_HTTP_PORT=15672
|
||||
MF_RABBITMQ_USER=mainflux
|
||||
MF_RABBITMQ_PASS=mainflux
|
||||
MF_RABBITMQ_COOKIE=mainflux
|
||||
MF_RABBITMQ_VHOST=/
|
||||
MF_RABBITMQ_URL=amqp://${MF_RABBITMQ_USER}:${MF_RABBITMQ_PASS}@broker:${MF_RABBITMQ_PORT}${MF_MF_RABBITMQ_VHOST}
|
||||
|
||||
## Redis
|
||||
MF_REDIS_TCP_PORT=6379
|
||||
|
@ -35,7 +35,7 @@ services:
|
||||
restart: on-failure
|
||||
environment:
|
||||
MF_CASSANDRA_WRITER_LOG_LEVEL: ${MF_CASSANDRA_WRITER_LOG_LEVEL}
|
||||
MF_NATS_URL: ${MF_NATS_URL}
|
||||
MF_BROKER_URL: ${MF_BROKER_URL}
|
||||
MF_CASSANDRA_WRITER_PORT: ${MF_CASSANDRA_WRITER_PORT}
|
||||
MF_CASSANDRA_WRITER_DB_PORT: ${MF_CASSANDRA_WRITER_DB_PORT}
|
||||
MF_CASSANDRA_WRITER_DB_CLUSTER: ${MF_CASSANDRA_WRITER_DB_CLUSTER}
|
||||
|
@ -41,7 +41,7 @@ services:
|
||||
restart: on-failure
|
||||
environment:
|
||||
MF_INFLUX_WRITER_LOG_LEVEL: debug
|
||||
MF_NATS_URL: ${MF_NATS_URL}
|
||||
MF_BROKER_URL: ${MF_BROKER_URL}
|
||||
MF_INFLUX_WRITER_PORT: ${MF_INFLUX_WRITER_PORT}
|
||||
MF_INFLUX_WRITER_BATCH_SIZE: ${MF_INFLUX_WRITER_BATCH_SIZE}
|
||||
MF_INFLUX_WRITER_BATCH_TIMEOUT: ${MF_INFLUX_WRITER_BATCH_TIMEOUT}
|
||||
|
@ -34,7 +34,7 @@ services:
|
||||
MF_LORA_ADAPTER_MESSAGES_PASS: ${MF_LORA_ADAPTER_MESSAGES_PASS}
|
||||
MF_LORA_ADAPTER_MESSAGES_TIMEOUT: ${MF_LORA_ADAPTER_MESSAGES_TIMEOUT}
|
||||
MF_LORA_ADAPTER_HTTP_PORT: ${MF_LORA_ADAPTER_HTTP_PORT}
|
||||
MF_NATS_URL: ${MF_NATS_URL}
|
||||
MF_BROKER_URL: ${MF_BROKER_URL}
|
||||
ports:
|
||||
- ${MF_LORA_ADAPTER_HTTP_PORT}:${MF_LORA_ADAPTER_HTTP_PORT}
|
||||
networks:
|
||||
|
@ -41,7 +41,7 @@ services:
|
||||
restart: on-failure
|
||||
environment:
|
||||
MF_MONGO_WRITER_LOG_LEVEL: ${MF_MONGO_WRITER_LOG_LEVEL}
|
||||
MF_NATS_URL: ${MF_NATS_URL}
|
||||
MF_BROKER_URL: ${MF_BROKER_URL}
|
||||
MF_MONGO_WRITER_PORT: ${MF_MONGO_WRITER_PORT}
|
||||
MF_MONGO_WRITER_DB: ${MF_MONGO_WRITER_DB}
|
||||
MF_MONGO_WRITER_DB_HOST: mongodb
|
||||
|
@ -33,7 +33,7 @@ services:
|
||||
environment:
|
||||
MF_OPCUA_ADAPTER_HTTP_PORT: ${MF_OPCUA_ADAPTER_HTTP_PORT}
|
||||
MF_OPCUA_ADAPTER_LOG_LEVEL: ${MF_OPCUA_ADAPTER_LOG_LEVEL}
|
||||
MF_NATS_URL: ${MF_NATS_URL}
|
||||
MF_BROKER_URL: ${MF_BROKER_URL}
|
||||
MF_OPCUA_ADAPTER_POLICY: ${MF_OPCUA_ADAPTER_POLICY}
|
||||
MF_OPCUA_ADAPTER_MODE: ${MF_OPCUA_ADAPTER_MODE}
|
||||
MF_OPCUA_ADAPTER_CERT_FILE: ${MF_OPCUA_ADAPTER_CERT_FILE}
|
||||
|
@ -38,7 +38,7 @@ services:
|
||||
- postgres
|
||||
restart: on-failure
|
||||
environment:
|
||||
MF_NATS_URL: ${MF_NATS_URL}
|
||||
MF_BROKER_URL: ${MF_BROKER_URL}
|
||||
MF_POSTGRES_WRITER_LOG_LEVEL: ${MF_POSTGRES_WRITER_LOG_LEVEL}
|
||||
MF_POSTGRES_WRITER_PORT: ${MF_POSTGRES_WRITER_PORT}
|
||||
MF_POSTGRES_WRITER_DB_HOST: postgres
|
||||
|
@ -36,7 +36,7 @@ services:
|
||||
- smpp-notifier-db
|
||||
restart: on-failure
|
||||
environment:
|
||||
MF_NATS_URL: ${MF_NATS_URL}
|
||||
MF_BROKER_URL: ${MF_BROKER_URL}
|
||||
MF_JAEGER_URL: ${MF_JAEGER_URL}
|
||||
MF_AUTH_GRPC_URL: ${MF_AUTH_GRPC_URL}
|
||||
MF_AUTH_GRPC_TIMEOUT: ${MF_AUTH_GRPC_TIMEOUT}
|
||||
|
@ -43,7 +43,7 @@ services:
|
||||
MF_SMTP_NOTIFIER_DB_PASS: ${MF_SMTP_NOTIFIER_DB_PASS}
|
||||
MF_SMTP_NOTIFIER_DB: ${MF_SMTP_NOTIFIER_DB}
|
||||
MF_SMTP_NOTIFIER_PORT: ${MF_SMTP_NOTIFIER_PORT}
|
||||
MF_NATS_URL: ${MF_NATS_URL}
|
||||
MF_BROKER_URL: ${MF_BROKER_URL}
|
||||
MF_JAEGER_URL: ${MF_JAEGER_URL}
|
||||
MF_AUTH_GRPC_URL: ${MF_AUTH_GRPC_URL}
|
||||
MF_AUTH_GRPC_TIMEOUT: ${MF_AUTH_GRPC_TIMEOUT}
|
||||
|
@ -38,7 +38,7 @@ services:
|
||||
- timescale
|
||||
restart: on-failure
|
||||
environment:
|
||||
MF_NATS_URL: ${MF_NATS_URL}
|
||||
MF_BROKER_URL: ${MF_BROKER_URL}
|
||||
MF_TIMESCALE_WRITER_LOG_LEVEL: ${MF_TIMESCALE_WRITER_LOG_LEVEL}
|
||||
MF_TIMESCALE_WRITER_PORT: ${MF_TIMESCALE_WRITER_PORT}
|
||||
MF_TIMESCALE_WRITER_DB_HOST: timescale
|
||||
|
@ -43,7 +43,7 @@ services:
|
||||
MF_TWINS_DB_HOST: ${MF_TWINS_DB_HOST}
|
||||
MF_TWINS_DB_PORT: ${MF_TWINS_DB_PORT}
|
||||
MF_TWINS_CHANNEL_ID: ${MF_TWINS_CHANNEL_ID}
|
||||
MF_NATS_URL: ${MF_NATS_URL}
|
||||
MF_BROKER_URL: ${MF_BROKER_URL}
|
||||
MF_AUTH_GRPC_URL: ${MF_AUTH_GRPC_URL}
|
||||
MF_AUTH_GRPC_TIMEOUT: ${MF_AUTH_GRPC_TIMEOUT}
|
||||
MF_TWINS_CACHE_URL: ${MF_TWINS_CACHE_URL}
|
||||
|
8
docker/brokers/nats.yml
Normal file
8
docker/brokers/nats.yml
Normal file
@ -0,0 +1,8 @@
|
||||
services:
|
||||
broker:
|
||||
image: nats:2.2.4-alpine
|
||||
command: "-c /etc/nats/nats.conf"
|
||||
volumes:
|
||||
- ./../nats/:/etc/nats
|
||||
ports:
|
||||
- ${MF_NATS_PORT}:${MF_NATS_PORT}
|
11
docker/brokers/rabbitmq.yml
Normal file
11
docker/brokers/rabbitmq.yml
Normal file
@ -0,0 +1,11 @@
|
||||
services:
|
||||
broker:
|
||||
image: rabbitmq:3.9.20-management-alpine
|
||||
environment:
|
||||
RABBITMQ_ERLANG_COOKIE: ${MF_RABBITMQ_COOKIE}
|
||||
RABBITMQ_DEFAULT_USER: ${MF_RABBITMQ_USER}
|
||||
RABBITMQ_DEFAULT_PASS: ${MF_RABBITMQ_PASS}
|
||||
RABBITMQ_DEFAULT_VHOST: ${MF_RABBITMQ_VHOST}
|
||||
ports:
|
||||
- ${MF_RABBITMQ_PORT}:${MF_RABBITMQ_PORT}
|
||||
- ${MF_RABBITMQ_HTTP_PORT}:${MF_RABBITMQ_HTTP_PORT}
|
@ -95,13 +95,12 @@ services:
|
||||
- mqtt-adapter
|
||||
- http-adapter
|
||||
|
||||
nats:
|
||||
image: nats:2.2.4-alpine
|
||||
container_name: mainflux-nats
|
||||
command: "-c /etc/nats/nats.conf"
|
||||
broker:
|
||||
extends:
|
||||
file: brokers/nats.yml
|
||||
service: broker
|
||||
container_name: mainflux-broker
|
||||
restart: on-failure
|
||||
volumes:
|
||||
- ./nats/:/etc/nats
|
||||
networks:
|
||||
- mainflux-base-net
|
||||
ports:
|
||||
@ -280,14 +279,14 @@ services:
|
||||
depends_on:
|
||||
- vernemq
|
||||
- things
|
||||
- nats
|
||||
- broker
|
||||
restart: on-failure
|
||||
environment:
|
||||
MF_MQTT_ADAPTER_LOG_LEVEL: ${MF_MQTT_ADAPTER_LOG_LEVEL}
|
||||
MF_MQTT_ADAPTER_MQTT_PORT: ${MF_MQTT_ADAPTER_MQTT_PORT}
|
||||
MF_MQTT_ADAPTER_WS_PORT: ${MF_MQTT_ADAPTER_WS_PORT}
|
||||
MF_MQTT_ADAPTER_ES_URL: es-redis:${MF_REDIS_TCP_PORT}
|
||||
MF_NATS_URL: ${MF_NATS_URL}
|
||||
MF_BROKER_URL: ${MF_NATS_URL}
|
||||
MF_MQTT_ADAPTER_MQTT_TARGET_HOST: vernemq
|
||||
MF_MQTT_ADAPTER_MQTT_TARGET_PORT: ${MF_MQTT_BROKER_PORT}
|
||||
MF_MQTT_ADAPTER_MQTT_TARGET_HEALTH_CHECK: http://vernemq:8888/health
|
||||
@ -305,12 +304,12 @@ services:
|
||||
container_name: mainflux-http
|
||||
depends_on:
|
||||
- things
|
||||
- nats
|
||||
- broker
|
||||
restart: on-failure
|
||||
environment:
|
||||
MF_HTTP_ADAPTER_LOG_LEVEL: debug
|
||||
MF_HTTP_ADAPTER_PORT: ${MF_HTTP_ADAPTER_PORT}
|
||||
MF_NATS_URL: ${MF_NATS_URL}
|
||||
MF_BROKER_URL: ${MF_NATS_URL}
|
||||
MF_JAEGER_URL: ${MF_JAEGER_URL}
|
||||
MF_THINGS_AUTH_GRPC_URL: ${MF_THINGS_AUTH_GRPC_URL}
|
||||
MF_THINGS_AUTH_GRPC_TIMEOUT: ${MF_THINGS_AUTH_GRPC_TIMEOUT}
|
||||
@ -333,12 +332,12 @@ services:
|
||||
container_name: mainflux-coap
|
||||
depends_on:
|
||||
- things
|
||||
- nats
|
||||
- broker
|
||||
restart: on-failure
|
||||
environment:
|
||||
MF_COAP_ADAPTER_LOG_LEVEL: ${MF_COAP_ADAPTER_LOG_LEVEL}
|
||||
MF_COAP_ADAPTER_PORT: ${MF_COAP_ADAPTER_PORT}
|
||||
MF_NATS_URL: ${MF_NATS_URL}
|
||||
MF_BROKER_URL: ${MF_NATS_URL}
|
||||
MF_JAEGER_URL: ${MF_JAEGER_URL}
|
||||
MF_THINGS_AUTH_GRPC_URL: ${MF_THINGS_AUTH_GRPC_URL}
|
||||
MF_THINGS_AUTH_GRPC_TIMEOUT: ${MF_THINGS_AUTH_GRPC_TIMEOUT}
|
||||
|
@ -8,16 +8,16 @@ The service is configured using the environment variables presented in the
|
||||
following table. Note that any unset variables will be replaced with their
|
||||
default values.
|
||||
|
||||
| Variable | Description | Default |
|
||||
| --------------------------- | --------------------------------------------------- | --------------------- |
|
||||
| MF_HTTP_ADAPTER_LOG_LEVEL | Log level for the HTTP Adapter | error |
|
||||
| MF_HTTP_ADAPTER_PORT | Service HTTP port | 8180 |
|
||||
| MF_NATS_URL | NATS instance URL | nats://localhost:4222 |
|
||||
| MF_HTTP_ADAPTER_CLIENT_TLS | Flag that indicates if TLS should be turned on | false |
|
||||
| MF_HTTP_ADAPTER_CA_CERTS | Path to trusted CAs in PEM format | |
|
||||
| MF_JAEGER_URL | Jaeger server URL | localhost:6831 |
|
||||
| MF_THINGS_AUTH_GRPC_URL | Things service Auth gRPC URL | localhost:8181 |
|
||||
| MF_THINGS_AUTH_GRPC_TIMEOUT | Things service Auth gRPC request timeout in seconds | 1s |
|
||||
| Variable | Description | Default |
|
||||
| --------------------------- | ------------------------------------------------------------- | --------------------- |
|
||||
| MF_HTTP_ADAPTER_LOG_LEVEL | Log level for the HTTP Adapter | error |
|
||||
| MF_HTTP_ADAPTER_PORT | Service HTTP port | 8180 |
|
||||
| MF_BROKER_URL | Message broker instance URL | nats://localhost:4222 |
|
||||
| MF_HTTP_ADAPTER_CLIENT_TLS | Flag that indicates if TLS should be turned on | false |
|
||||
| MF_HTTP_ADAPTER_CA_CERTS | Path to trusted CAs in PEM format | |
|
||||
| MF_JAEGER_URL | Jaeger server URL | localhost:6831 |
|
||||
| MF_THINGS_AUTH_GRPC_URL | Things service Auth gRPC URL | localhost:8181 |
|
||||
| MF_THINGS_AUTH_GRPC_TIMEOUT | Things service Auth gRPC request timeout in seconds | 1s |
|
||||
|
||||
## Deployment
|
||||
|
||||
@ -39,7 +39,7 @@ make http
|
||||
make install
|
||||
|
||||
# set the environment variables and run the service
|
||||
MF_NATS_URL=[NATS instance URL] \
|
||||
MF_BROKER_URL=[Message broker instance URL] \
|
||||
MF_HTTP_ADAPTER_LOG_LEVEL=[HTTP Adapter Log Level] \
|
||||
MF_HTTP_ADAPTER_PORT=[Service HTTP port] \
|
||||
MF_HTTP_ADAPTER_CA_CERTS=[Path to trusted CAs in PEM format] \
|
||||
|
@ -17,3 +17,7 @@ func NewPublisher() messaging.Publisher {
|
||||
func (pub mockPublisher) Publish(topic string, msg messaging.Message) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pub mockPublisher) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ default values.
|
||||
|----------------------------------|---------------------------------------|---------------------------------|
|
||||
| MF_LORA_ADAPTER_HTTP_PORT | Service HTTP port | 8180 |
|
||||
| MF_LORA_ADAPTER_LOG_LEVEL | Service Log level | error |
|
||||
| MF_NATS_URL | NATS instance URL | nats://localhost:4222 |
|
||||
| MF_BROKER_URL | Message broker instance URL | nats://localhost:4222 |
|
||||
| MF_LORA_ADAPTER_MESSAGES_URL | LoRa adapter MQTT broker URL | tcp://localhost:1883 |
|
||||
| MF_LORA_ADAPTER_MESSAGES_TOPIC | LoRa adapter MQTT subscriber Topic | application/+/device/+/event/up |
|
||||
| MF_LORA_ADAPTER_MESSAGES_USER | LoRa adapter MQTT subscriber Username | |
|
||||
@ -50,7 +50,7 @@ make install
|
||||
|
||||
# set the environment variables and run the service
|
||||
MF_LORA_ADAPTER_LOG_LEVEL=[Lora Adapter Log Level] \
|
||||
MF_NATS_URL=[NATS instance URL] \
|
||||
MF_BROKER_URL=[Message broker instance URL] \
|
||||
MF_LORA_ADAPTER_MESSAGES_URL=[LoRa adapter MQTT broker URL] \
|
||||
MF_LORA_ADAPTER_MESSAGES_TOPIC=[LoRa adapter MQTT subscriber Topic] \
|
||||
MF_LORA_ADAPTER_MESSAGES_USER=[LoRa adapter MQTT subscriber Username] \
|
||||
|
@ -54,7 +54,7 @@ type Service interface {
|
||||
// DisconnectThing removes thingID:channelID route-map
|
||||
DisconnectThing(ctx context.Context, chanID, thingID string) error
|
||||
|
||||
// Publish forwards messages from the LoRa MQTT broker to Mainflux NATS broker
|
||||
// Publish forwards messages from the LoRa MQTT broker to Mainflux Message Broker
|
||||
Publish(ctx context.Context, msg Message) error
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ func New(publisher messaging.Publisher, thingsRM, channelsRM, connectRM RouteMap
|
||||
}
|
||||
}
|
||||
|
||||
// Publish forwards messages from Lora MQTT broker to Mainflux NATS broker
|
||||
// Publish forwards messages from Lora MQTT broker to Mainflux Message broker
|
||||
func (as *adapterService) Publish(ctx context.Context, m Message) error {
|
||||
// Get route map of lora application
|
||||
thingID, err := as.thingsRM.Get(ctx, m.DevEUI)
|
||||
@ -113,7 +113,7 @@ func (as *adapterService) Publish(ctx context.Context, m Message) error {
|
||||
payload = []byte(jo)
|
||||
}
|
||||
|
||||
// Publish on Mainflux NATS broker
|
||||
// Publish on Mainflux Message broker
|
||||
msg := messaging.Message{
|
||||
Publisher: thingID,
|
||||
Protocol: protocol,
|
||||
|
@ -17,3 +17,7 @@ func NewPublisher() messaging.Publisher {
|
||||
func (pub mockPublisher) Publish(topic string, msg messaging.Message) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pub mockPublisher) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
@ -10,31 +10,31 @@ The service is configured using the environment variables presented in the
|
||||
following table. Note that any unset variables will be replaced with their
|
||||
default values.
|
||||
|
||||
| Variable | Description | Default |
|
||||
|------------------------------------------|--------------------------------------------------------|-----------------------|
|
||||
| MF_MQTT_ADAPTER_LOG_LEVEL | mProxy Log level | error |
|
||||
| MF_MQTT_ADAPTER_MQTT_PORT | mProxy port | 1883 |
|
||||
| MF_MQTT_ADAPTER_MQTT_TARGET_HOST | MQTT broker host | 0.0.0.0 |
|
||||
| MF_MQTT_ADAPTER_MQTT_TARGET_PORT | MQTT broker port | 1883 |
|
||||
| MF_MQTT_ADAPTER_MQTT_TARGET_HEALTH_CHECK | URL of broker health check | "" |
|
||||
| MF_MQTT_ADAPTER_WS_PORT | mProxy MQTT over WS port | 8080 |
|
||||
| MF_MQTT_ADAPTER_WS_TARGET_HOST | MQTT broker host for MQTT over WS | localhost |
|
||||
| MF_MQTT_ADAPTER_WS_TARGET_PORT | MQTT broker port for MQTT over WS | 8080 |
|
||||
| MF_MQTT_ADAPTER_WS_TARGET_PATH | MQTT broker MQTT over WS path | /mqtt |
|
||||
| MF_MQTT_ADAPTER_FORWARDER_TIMEOUT | MQTT forwarder for multiprotocol communication timeout | 30s |
|
||||
| MF_NATS_URL | NATS broker URL | nats://127.0.0.1:4222 |
|
||||
| MF_THINGS_AUTH_GRPC_URL | Things gRPC endpoint URL | localhost:8181 |
|
||||
| MF_THINGS_AUTH_GRPC_TIMEOUT | Timeout in seconds for Things service gRPC calls | 1s |
|
||||
| MF_JAEGER_URL | URL of Jaeger tracing service | "" |
|
||||
| MF_MQTT_ADAPTER_CLIENT_TLS | gRPC client TLS | false |
|
||||
| MF_MQTT_ADAPTER_CA_CERTS | CA certs for gRPC client TLS | "" |
|
||||
| MF_MQTT_ADAPTER_INSTANCE | Instance name for event sourcing | "" |
|
||||
| MF_MQTT_ADAPTER_ES_URL | Event sourcing URL | localhost:6379 |
|
||||
| MF_MQTT_ADAPTER_ES_PASS | Event sourcing password | "" |
|
||||
| MF_MQTT_ADAPTER_ES_DB | Event sourcing database | "0" |
|
||||
| MF_AUTH_CACHE_URL | Auth cache URL | localhost:6379 |
|
||||
| MF_AUTH_CACHE_PASS | Auth cache password | "" |
|
||||
| MF_AUTH_CACHE_DB | Auth cache database | "0" |
|
||||
| Variable | Description | Default |
|
||||
|------------------------------------------|------------------------------------------------------------------|-----------------------|
|
||||
| MF_MQTT_ADAPTER_LOG_LEVEL | mProxy Log level | error |
|
||||
| MF_MQTT_ADAPTER_MQTT_PORT | mProxy port | 1883 |
|
||||
| MF_MQTT_ADAPTER_MQTT_TARGET_HOST | MQTT broker host | 0.0.0.0 |
|
||||
| MF_MQTT_ADAPTER_MQTT_TARGET_PORT | MQTT broker port | 1883 |
|
||||
| MF_MQTT_ADAPTER_MQTT_TARGET_HEALTH_CHECK | URL of broker health check | "" |
|
||||
| MF_MQTT_ADAPTER_WS_PORT | mProxy MQTT over WS port | 8080 |
|
||||
| MF_MQTT_ADAPTER_WS_TARGET_HOST | MQTT broker host for MQTT over WS | localhost |
|
||||
| MF_MQTT_ADAPTER_WS_TARGET_PORT | MQTT broker port for MQTT over WS | 8080 |
|
||||
| MF_MQTT_ADAPTER_WS_TARGET_PATH | MQTT broker MQTT over WS path | /mqtt |
|
||||
| MF_MQTT_ADAPTER_FORWARDER_TIMEOUT | MQTT forwarder for multiprotocol communication timeout | 30s |
|
||||
| MF_BROKER_URL | Message broker broker URL | nats://127.0.0.1:4222 |
|
||||
| MF_THINGS_AUTH_GRPC_URL | Things gRPC endpoint URL | localhost:8181 |
|
||||
| MF_THINGS_AUTH_GRPC_TIMEOUT | Timeout in seconds for Things service gRPC calls | 1s |
|
||||
| MF_JAEGER_URL | URL of Jaeger tracing service | "" |
|
||||
| MF_MQTT_ADAPTER_CLIENT_TLS | gRPC client TLS | false |
|
||||
| MF_MQTT_ADAPTER_CA_CERTS | CA certs for gRPC client TLS | "" |
|
||||
| MF_MQTT_ADAPTER_INSTANCE | Instance name for event sourcing | "" |
|
||||
| MF_MQTT_ADAPTER_ES_URL | Event sourcing URL | localhost:6379 |
|
||||
| MF_MQTT_ADAPTER_ES_PASS | Event sourcing password | "" |
|
||||
| MF_MQTT_ADAPTER_ES_DB | Event sourcing database | "0" |
|
||||
| MF_AUTH_CACHE_URL | Auth cache URL | localhost:6379 |
|
||||
| MF_AUTH_CACHE_PASS | Auth cache password | "" |
|
||||
| MF_AUTH_CACHE_DB | Auth cache database | "0" |
|
||||
|
||||
## Deployment
|
||||
|
||||
@ -66,7 +66,7 @@ MF_MQTT_ADAPTER_WS_TARGET_HOST=[MQTT broker for MQTT over WS host] \
|
||||
MF_MQTT_ADAPTER_WS_TARGET_PORT=[MQTT broker for MQTT over WS port]] \
|
||||
MF_MQTT_ADAPTER_WS_TARGET_PATH=[MQTT adapter WS path] \
|
||||
MF_MQTT_ADAPTER_FORWARDER_TIMEOUT=[MQTT forwarder for multiprotocol support timeout] \
|
||||
MF_NATS_URL=[NATS instance URL] \
|
||||
MF_BROKER_URL=[Message broker instance URL] \
|
||||
MF_THINGS_AUTH_GRPC_URL=[Things service Auth gRPC URL] \
|
||||
MF_THINGS_AUTH_GRPC_TIMEOUT=[Things service Auth gRPC request timeout in seconds] \
|
||||
MF_JAEGER_URL=[Jaeger service URL] \
|
||||
|
@ -11,23 +11,23 @@ The service is configured using the environment variables presented in the
|
||||
following table. Note that any unset variables will be replaced with their
|
||||
default values.
|
||||
|
||||
| Variable | Description | Default |
|
||||
|----------------------------------|----------------------------------------|----------------------------|
|
||||
| MF_OPCUA_ADAPTER_HTTP_PORT | Service HTTP port | 8180 |
|
||||
| MF_OPCUA_ADAPTER_LOG_LEVEL | Service Log level | error |
|
||||
| MF_NATS_URL | NATS instance URL | nats://localhost:4222 |
|
||||
| MF_OPCUA_ADAPTER_INTERVAL_MS | OPC-UA Server Interval in milliseconds | 1000 |
|
||||
| MF_OPCUA_ADAPTER_POLICY | OPC-UA Server Policy | |
|
||||
| MF_OPCUA_ADAPTER_MODE | OPC-UA Server Mode | |
|
||||
| MF_OPCUA_ADAPTER_CERT_FILE | OPC-UA Server Certificate file | |
|
||||
| MF_OPCUA_ADAPTER_KEY_FILE | OPC-UA Server Key file | |
|
||||
| MF_OPCUA_ADAPTER_ROUTE_MAP_URL | Route-map database URL | localhost:6379 |
|
||||
| MF_OPCUA_ADAPTER_ROUTE_MAP_PASS | Route-map database password | |
|
||||
| MF_OPCUA_ADAPTER_ROUTE_MAP_DB | Route-map instance name | 0 |
|
||||
| MF_THINGS_ES_URL | Things service event source URL | localhost:6379 |
|
||||
| MF_THINGS_ES_PASS | Things service event source password | |
|
||||
| MF_THINGS_ES_DB | Things service event source DB | 0 |
|
||||
| MF_OPCUA_ADAPTER_EVENT_CONSUMER | Service event consumer name | opcua |
|
||||
| Variable | Description | Default |
|
||||
|----------------------------------|--------------------------------------------------|----------------------------|
|
||||
| MF_OPCUA_ADAPTER_HTTP_PORT | Service HTTP port | 8180 |
|
||||
| MF_OPCUA_ADAPTER_LOG_LEVEL | Service Log level | error |
|
||||
| MF_BROKER_URL | Message broker instance URL | nats://localhost:4222 |
|
||||
| MF_OPCUA_ADAPTER_INTERVAL_MS | OPC-UA Server Interval in milliseconds | 1000 |
|
||||
| MF_OPCUA_ADAPTER_POLICY | OPC-UA Server Policy | |
|
||||
| MF_OPCUA_ADAPTER_MODE | OPC-UA Server Mode | |
|
||||
| MF_OPCUA_ADAPTER_CERT_FILE | OPC-UA Server Certificate file | |
|
||||
| MF_OPCUA_ADAPTER_KEY_FILE | OPC-UA Server Key file | |
|
||||
| MF_OPCUA_ADAPTER_ROUTE_MAP_URL | Route-map database URL | localhost:6379 |
|
||||
| MF_OPCUA_ADAPTER_ROUTE_MAP_PASS | Route-map database password | |
|
||||
| MF_OPCUA_ADAPTER_ROUTE_MAP_DB | Route-map instance name | 0 |
|
||||
| MF_THINGS_ES_URL | Things service event source URL | localhost:6379 |
|
||||
| MF_THINGS_ES_PASS | Things service event source password | |
|
||||
| MF_THINGS_ES_DB | Things service event source DB | 0 |
|
||||
| MF_OPCUA_ADAPTER_EVENT_CONSUMER | Service event consumer name | opcua |
|
||||
|
||||
## Deployment
|
||||
|
||||
@ -51,7 +51,7 @@ make install
|
||||
# set the environment variables and run the service
|
||||
MF_OPCUA_ADAPTER_HTTP_PORT=[Service HTTP port] \
|
||||
MF_OPCUA_ADAPTER_LOG_LEVEL=[OPC-UA Adapter Log Level] \
|
||||
MF_NATS_URL=[NATS instance URL] \
|
||||
MF_BROKER_URL=[Message broker instance URL] \
|
||||
MF_OPCUA_ADAPTER_INTERVAL_MS: [OPC-UA Server Interval (milliseconds)] \
|
||||
MF_OPCUA_ADAPTER_POLICY=[OPC-UA Server Policy] \
|
||||
MF_OPCUA_ADAPTER_MODE=[OPC-UA Server Mode] \
|
||||
|
@ -203,7 +203,7 @@ func (c client) runHandler(ctx context.Context, sub *opcuaGopcua.Subscription, u
|
||||
}
|
||||
}
|
||||
|
||||
// Publish forwards messages from the OPC-UA Server to Mainflux NATS broker
|
||||
// Publish forwards messages from the OPC-UA Server to Mainflux Message broker
|
||||
func (c client) publish(ctx context.Context, token string, m message) error {
|
||||
// Get route-map of the OPC-UA ServerURI
|
||||
chanID, err := c.channelsRM.Get(ctx, m.ServerURI)
|
||||
@ -223,7 +223,7 @@ func (c client) publish(ctx context.Context, token string, m message) error {
|
||||
return fmt.Errorf("%s between channel %s and thing %s", errNotFoundConn, chanID, thingID)
|
||||
}
|
||||
|
||||
// Publish on Mainflux NATS broker
|
||||
// Publish on Mainflux Message broker
|
||||
SenML := fmt.Sprintf(`[{"n":"%s", "t": %d, "%s":%v}]`, m.Type, m.Time, m.DataKey, m.Data)
|
||||
payload := []byte(SenML)
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
`messaging` package defines `Publisher`, `Subscriber` and an aggregate `Pubsub` interface.
|
||||
|
||||
`Subscriber` interface defines methods used to subscribe to a message broker such as MQTT or NATS.
|
||||
`Subscriber` interface defines methods used to subscribe to a message broker such as MQTT or NATS or RabbitMQ.
|
||||
|
||||
`Publisher` interface defines methods used to publish messages to a message broker such as MQTT or NATS.
|
||||
`Publisher` interface defines methods used to publish messages to a message broker such as MQTT or NATS or RabbitMQ.
|
||||
|
||||
`Pubsub` interface is composed of `Publisher` and `Subscriber` interface and can be used to send messages to as well as to receive messages from a message broker.
|
||||
|
39
pkg/messaging/brokers/brokers_nats.go
Normal file
39
pkg/messaging/brokers/brokers_nats.go
Normal file
@ -0,0 +1,39 @@
|
||||
//go:build !rabbitmq
|
||||
// +build !rabbitmq
|
||||
|
||||
// Copyright (c) Mainflux
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package brokers
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/messaging"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/nats"
|
||||
)
|
||||
|
||||
// SubjectAllChannels represents subject to subscribe for all the channels.
|
||||
const SubjectAllChannels = "channels.>"
|
||||
|
||||
func init() {
|
||||
log.Println("The binary was build using Nats as the message broker")
|
||||
}
|
||||
|
||||
func NewPublisher(url string) (messaging.Publisher, error) {
|
||||
pb, err := nats.NewPublisher(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return pb, nil
|
||||
|
||||
}
|
||||
|
||||
func NewPubSub(url, queue string, logger logger.Logger) (messaging.PubSub, error) {
|
||||
pb, err := nats.NewPubSub(url, queue, logger)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return pb, nil
|
||||
}
|
38
pkg/messaging/brokers/brokers_rabbitmq.go
Normal file
38
pkg/messaging/brokers/brokers_rabbitmq.go
Normal file
@ -0,0 +1,38 @@
|
||||
//go:build rabbitmq
|
||||
// +build rabbitmq
|
||||
|
||||
// Copyright (c) Mainflux
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package brokers
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/messaging"
|
||||
"github.com/mainflux/mainflux/pkg/messaging/rabbitmq"
|
||||
)
|
||||
|
||||
// SubjectAllChannels represents subject to subscribe for all the channels.
|
||||
const SubjectAllChannels = "channels.>"
|
||||
|
||||
func init() {
|
||||
log.Println("The binary was build using RabbitMQ as the message broker")
|
||||
}
|
||||
|
||||
func NewPublisher(url string) (messaging.Publisher, error) {
|
||||
pb, err := rabbitmq.NewPublisher(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return pb, nil
|
||||
}
|
||||
|
||||
func NewPubSub(url, queue string, logger logger.Logger) (messaging.PubSub, error) {
|
||||
pb, err := rabbitmq.NewPubSub(url, queue, logger)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return pb, nil
|
||||
}
|
@ -23,7 +23,7 @@ type publisher struct {
|
||||
|
||||
// NewPublisher returns a new MQTT message publisher.
|
||||
func NewPublisher(address string, timeout time.Duration) (messaging.Publisher, error) {
|
||||
client, err := newClient(address, timeout)
|
||||
client, err := newClient(address, "mqtt-publisher", timeout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -47,3 +47,8 @@ func (pub publisher) Publish(topic string, msg messaging.Message) error {
|
||||
|
||||
return token.Error()
|
||||
}
|
||||
|
||||
func (pub publisher) Close() error {
|
||||
pub.client.Disconnect(uint(pub.timeout))
|
||||
return nil
|
||||
}
|
||||
|
@ -5,9 +5,14 @@ package mqtt
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
log "github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/messaging"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -15,12 +20,142 @@ const (
|
||||
qos = 2
|
||||
)
|
||||
|
||||
var errConnect = errors.New("failed to connect to MQTT broker")
|
||||
var (
|
||||
errConnect = errors.New("failed to connect to MQTT broker")
|
||||
errSubscribeTimeout = errors.New("failed to subscribe due to timeout reached")
|
||||
errUnsubscribeTimeout = errors.New("failed to unsubscribe due to timeout reached")
|
||||
errUnsubscribeDeleteTopic = errors.New("failed to unsubscribe due to deletion of topic")
|
||||
errAlreadySubscribed = errors.New("already subscribed to topic")
|
||||
errNotSubscribed = errors.New("not subscribed")
|
||||
errEmptyTopic = errors.New("empty topic")
|
||||
errEmptyID = errors.New("empty ID")
|
||||
)
|
||||
|
||||
func newClient(address string, timeout time.Duration) (mqtt.Client, error) {
|
||||
opts := mqtt.NewClientOptions().
|
||||
SetUsername(username).
|
||||
AddBroker(address)
|
||||
var _ messaging.PubSub = (*pubsub)(nil)
|
||||
|
||||
type subscription struct {
|
||||
client mqtt.Client
|
||||
topics []string
|
||||
}
|
||||
|
||||
type pubsub struct {
|
||||
publisher
|
||||
logger log.Logger
|
||||
mu *sync.RWMutex
|
||||
address string
|
||||
timeout time.Duration
|
||||
subscriptions map[string]subscription
|
||||
}
|
||||
|
||||
func NewPubSub(url, queue string, timeout time.Duration, logger log.Logger) (messaging.PubSub, error) {
|
||||
client, err := newClient(url, "mqtt-publisher", timeout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := pubsub{
|
||||
publisher: publisher{
|
||||
client: client,
|
||||
timeout: timeout,
|
||||
},
|
||||
address: url,
|
||||
timeout: timeout,
|
||||
logger: logger,
|
||||
subscriptions: make(map[string]subscription),
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (ps pubsub) Subscribe(id, topic string, handler messaging.MessageHandler) error {
|
||||
if id == "" {
|
||||
return errEmptyID
|
||||
}
|
||||
if topic == "" {
|
||||
return errEmptyTopic
|
||||
}
|
||||
ps.mu.Lock()
|
||||
defer ps.mu.Unlock()
|
||||
// Check client ID
|
||||
s, ok := ps.subscriptions[id]
|
||||
switch ok {
|
||||
case true:
|
||||
// Check topic
|
||||
if ok = s.contains(topic); ok {
|
||||
return errAlreadySubscribed
|
||||
}
|
||||
s.topics = append(s.topics, topic)
|
||||
default:
|
||||
client, err := newClient(ps.address, id, ps.timeout)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s = subscription{
|
||||
client: client,
|
||||
topics: []string{topic},
|
||||
}
|
||||
}
|
||||
token := s.client.Subscribe(topic, qos, ps.mqttHandler(handler))
|
||||
if token.Error() != nil {
|
||||
return token.Error()
|
||||
}
|
||||
if ok := token.WaitTimeout(ps.timeout); !ok {
|
||||
return errSubscribeTimeout
|
||||
}
|
||||
return token.Error()
|
||||
}
|
||||
|
||||
func (ps pubsub) Unsubscribe(id, topic string) error {
|
||||
if id == "" {
|
||||
return errEmptyID
|
||||
}
|
||||
if topic == "" {
|
||||
return errEmptyTopic
|
||||
}
|
||||
ps.mu.Lock()
|
||||
defer ps.mu.Unlock()
|
||||
// Check client ID
|
||||
s, ok := ps.subscriptions[id]
|
||||
switch ok {
|
||||
case true:
|
||||
// Check topic
|
||||
if ok := s.contains(topic); !ok {
|
||||
return errNotSubscribed
|
||||
}
|
||||
default:
|
||||
return errNotSubscribed
|
||||
}
|
||||
token := s.client.Unsubscribe(topic)
|
||||
if token.Error() != nil {
|
||||
return token.Error()
|
||||
}
|
||||
|
||||
ok = token.WaitTimeout(ps.timeout)
|
||||
if !ok {
|
||||
return errUnsubscribeTimeout
|
||||
}
|
||||
if ok := s.delete(topic); !ok {
|
||||
return errUnsubscribeDeleteTopic
|
||||
}
|
||||
if len(s.topics) == 0 {
|
||||
delete(ps.subscriptions, id)
|
||||
}
|
||||
return token.Error()
|
||||
}
|
||||
|
||||
func (ps pubsub) mqttHandler(h messaging.MessageHandler) mqtt.MessageHandler {
|
||||
return func(c mqtt.Client, m mqtt.Message) {
|
||||
var msg messaging.Message
|
||||
if err := proto.Unmarshal(m.Payload(), &msg); err != nil {
|
||||
ps.logger.Warn(fmt.Sprintf("Failed to unmarshal received message: %s", err))
|
||||
return
|
||||
}
|
||||
if err := h.Handle(msg); err != nil {
|
||||
ps.logger.Warn(fmt.Sprintf("Failed to handle Mainflux message: %s", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func newClient(address, id string, timeout time.Duration) (mqtt.Client, error) {
|
||||
opts := mqtt.NewClientOptions().SetUsername(username).AddBroker(address).SetClientID(id)
|
||||
client := mqtt.NewClient(opts)
|
||||
token := client.Connect()
|
||||
if token.Error() != nil {
|
||||
@ -38,3 +173,31 @@ func newClient(address string, timeout time.Duration) (mqtt.Client, error) {
|
||||
|
||||
return client, nil
|
||||
}
|
||||
|
||||
// contains checks if a topic is present
|
||||
func (sub subscription) contains(topic string) bool {
|
||||
return sub.indexOf(topic) != -1
|
||||
}
|
||||
|
||||
// Finds the index of an item in the topics
|
||||
func (sub subscription) indexOf(element string) int {
|
||||
for k, v := range sub.topics {
|
||||
if element == v {
|
||||
return k
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// Deletes a topic from the slice
|
||||
func (sub subscription) delete(topic string) bool {
|
||||
index := sub.indexOf(topic)
|
||||
if index == -1 {
|
||||
return false
|
||||
}
|
||||
topics := make([]string, len(sub.topics)-1)
|
||||
copy(topics[:index], sub.topics[:index])
|
||||
copy(topics[index:], sub.topics[index+1:])
|
||||
sub.topics = topics
|
||||
return true
|
||||
}
|
||||
|
@ -1,172 +0,0 @@
|
||||
// Copyright (c) Mainflux
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package mqtt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
|
||||
log "github.com/mainflux/mainflux/logger"
|
||||
"github.com/mainflux/mainflux/pkg/errors"
|
||||
"github.com/mainflux/mainflux/pkg/messaging"
|
||||
)
|
||||
|
||||
var (
|
||||
errSubscribeTimeout = errors.New("failed to subscribe due to timeout reached")
|
||||
errUnsubscribeTimeout = errors.New("failed to unsubscribe due to timeout reached")
|
||||
errUnsubscribeDeleteTopic = errors.New("failed to unsubscribe due to deletion of topic")
|
||||
errAlreadySubscribed = errors.New("already subscribed to topic")
|
||||
errNotSubscribed = errors.New("not subscribed")
|
||||
errEmptyTopic = errors.New("empty topic")
|
||||
errEmptyID = errors.New("empty ID")
|
||||
)
|
||||
|
||||
var _ messaging.Subscriber = (*subscriber)(nil)
|
||||
|
||||
type subscription struct {
|
||||
client mqtt.Client
|
||||
topics []string
|
||||
}
|
||||
|
||||
type subscriber struct {
|
||||
address string
|
||||
timeout time.Duration
|
||||
logger log.Logger
|
||||
subscriptions map[string]subscription
|
||||
mu *sync.RWMutex
|
||||
}
|
||||
|
||||
// NewSubscriber returns a new MQTT message subscriber.
|
||||
func NewSubscriber(address string, timeout time.Duration, logger log.Logger) (messaging.Subscriber, error) {
|
||||
ret := subscriber{
|
||||
address: address,
|
||||
timeout: timeout,
|
||||
logger: logger,
|
||||
subscriptions: make(map[string]subscription),
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (sub subscriber) Subscribe(id, topic string, handler messaging.MessageHandler) error {
|
||||
if id == "" {
|
||||
return errEmptyID
|
||||
}
|
||||
if topic == "" {
|
||||
return errEmptyTopic
|
||||
}
|
||||
sub.mu.Lock()
|
||||
defer sub.mu.Unlock()
|
||||
// Check client ID
|
||||
s, ok := sub.subscriptions[id]
|
||||
switch ok {
|
||||
case true:
|
||||
// Check topic
|
||||
if ok = s.contains(topic); ok {
|
||||
return errAlreadySubscribed
|
||||
}
|
||||
s.topics = append(s.topics, topic)
|
||||
default:
|
||||
opts := mqtt.NewClientOptions().SetUsername(username).AddBroker(sub.address).SetClientID(id)
|
||||
client := mqtt.NewClient(opts)
|
||||
token := client.Connect()
|
||||
if token.Error() != nil {
|
||||
return token.Error()
|
||||
}
|
||||
s = subscription{
|
||||
client: client,
|
||||
topics: []string{topic},
|
||||
}
|
||||
}
|
||||
token := s.client.Subscribe(topic, qos, sub.mqttHandler(handler))
|
||||
if token.Error() != nil {
|
||||
return token.Error()
|
||||
}
|
||||
if ok := token.WaitTimeout(sub.timeout); !ok {
|
||||
return errSubscribeTimeout
|
||||
}
|
||||
return token.Error()
|
||||
}
|
||||
|
||||
func (sub subscriber) Unsubscribe(id, topic string) error {
|
||||
if id == "" {
|
||||
return errEmptyID
|
||||
}
|
||||
if topic == "" {
|
||||
return errEmptyTopic
|
||||
}
|
||||
sub.mu.Lock()
|
||||
defer sub.mu.Unlock()
|
||||
// Check client ID
|
||||
s, ok := sub.subscriptions[id]
|
||||
switch ok {
|
||||
case true:
|
||||
// Check topic
|
||||
if ok := s.contains(topic); !ok {
|
||||
return errNotSubscribed
|
||||
}
|
||||
default:
|
||||
return errNotSubscribed
|
||||
}
|
||||
token := s.client.Unsubscribe(topic)
|
||||
if token.Error() != nil {
|
||||
return token.Error()
|
||||
}
|
||||
|
||||
ok = token.WaitTimeout(sub.timeout)
|
||||
if !ok {
|
||||
return errUnsubscribeTimeout
|
||||
}
|
||||
if ok := s.delete(topic); !ok {
|
||||
return errUnsubscribeDeleteTopic
|
||||
}
|
||||
if len(s.topics) == 0 {
|
||||
delete(sub.subscriptions, id)
|
||||
}
|
||||
return token.Error()
|
||||
}
|
||||
|
||||
func (sub subscriber) mqttHandler(h messaging.MessageHandler) mqtt.MessageHandler {
|
||||
return func(c mqtt.Client, m mqtt.Message) {
|
||||
var msg messaging.Message
|
||||
if err := proto.Unmarshal(m.Payload(), &msg); err != nil {
|
||||
sub.logger.Warn(fmt.Sprintf("Failed to unmarshal received message: %s", err))
|
||||
return
|
||||
}
|
||||
if err := h.Handle(msg); err != nil {
|
||||
sub.logger.Warn(fmt.Sprintf("Failed to handle Mainflux message: %s", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// contains checks if a topic is present
|
||||
func (sub subscription) contains(topic string) bool {
|
||||
return sub.indexOf(topic) != -1
|
||||
}
|
||||
|
||||
// Finds the index of an item in the topics
|
||||
func (sub subscription) indexOf(element string) int {
|
||||
for k, v := range sub.topics {
|
||||
if element == v {
|
||||
return k
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// Deletes a topic from the slice
|
||||
func (sub subscription) delete(topic string) bool {
|
||||
index := sub.indexOf(topic)
|
||||
if index == -1 {
|
||||
return false
|
||||
}
|
||||
topics := make([]string, len(sub.topics)-1)
|
||||
copy(topics[:index], sub.topics[:index])
|
||||
copy(topics[index:], sub.topics[index+1:])
|
||||
sub.topics = topics
|
||||
return true
|
||||
}
|
@ -19,13 +19,9 @@ type publisher struct {
|
||||
|
||||
// Publisher wraps messaging Publisher exposing
|
||||
// Close() method for NATS connection.
|
||||
type Publisher interface {
|
||||
messaging.Publisher
|
||||
Close()
|
||||
}
|
||||
|
||||
// NewPublisher returns NATS message Publisher.
|
||||
func NewPublisher(url string) (Publisher, error) {
|
||||
func NewPublisher(url string) (messaging.Publisher, error) {
|
||||
conn, err := broker.Connect(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -56,6 +52,7 @@ func (pub *publisher) Publish(topic string, msg messaging.Message) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pub *publisher) Close() {
|
||||
func (pub *publisher) Close() error {
|
||||
pub.conn.Close()
|
||||
return nil
|
||||
}
|
||||
|
@ -17,9 +17,6 @@ import (
|
||||
|
||||
const chansPrefix = "channels"
|
||||
|
||||
// SubjectAllChannels represents subject to subscribe for all the channels.
|
||||
const SubjectAllChannels = "channels.>"
|
||||
|
||||
var (
|
||||
ErrAlreadySubscribed = errors.New("already subscribed to topic")
|
||||
ErrNotSubscribed = errors.New("not subscribed")
|
||||
@ -29,13 +26,6 @@ var (
|
||||
|
||||
var _ messaging.PubSub = (*pubsub)(nil)
|
||||
|
||||
// PubSub wraps messaging Publisher exposing
|
||||
// Close() method for NATS connection.
|
||||
type PubSub interface {
|
||||
messaging.PubSub
|
||||
Close()
|
||||
}
|
||||
|
||||
type subscription struct {
|
||||
*broker.Subscription
|
||||
cancel func() error
|
||||
@ -56,7 +46,7 @@ type pubsub struct {
|
||||
// from ordinary subscribe. For more information, please take a look
|
||||
// here: https://docs.nats.io/developing-with-nats/receiving/queues.
|
||||
// If the queue is empty, Subscribe will be used.
|
||||
func NewPubSub(url, queue string, logger log.Logger) (PubSub, error) {
|
||||
func NewPubSub(url, queue string, logger log.Logger) (messaging.PubSub, error) {
|
||||
conn, err := broker.Connect(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -7,6 +7,9 @@ package messaging
|
||||
type Publisher interface {
|
||||
// Publishes message to the stream.
|
||||
Publish(topic string, msg Message) error
|
||||
|
||||
// Close gracefully closes message publisher's connection.
|
||||
Close() error
|
||||
}
|
||||
|
||||
// MessageHandler represents Message handler for Subscriber.
|
||||
@ -26,6 +29,9 @@ type Subscriber interface {
|
||||
// Unsubscribe unsubscribes from the message stream and
|
||||
// stops consuming messages.
|
||||
Unsubscribe(id, topic string) error
|
||||
|
||||
// Close gracefully closes message subscriber's connection.
|
||||
Close() error
|
||||
}
|
||||
|
||||
// PubSub represents aggregation interface for publisher and subscriber.
|
||||
|
@ -18,17 +18,9 @@ type publisher struct {
|
||||
ch *amqp.Channel
|
||||
}
|
||||
|
||||
// Publisher wraps messaging Publisher exposing
|
||||
// Close() method for RabbitMQ connection.
|
||||
type Publisher interface {
|
||||
messaging.Publisher
|
||||
Close()
|
||||
}
|
||||
|
||||
// NewPublisher returns RabbitMQ message Publisher.
|
||||
func NewPublisher(url string) (Publisher, error) {
|
||||
endpoint := fmt.Sprintf("amqp://%s", url)
|
||||
conn, err := amqp.Dial(endpoint)
|
||||
func NewPublisher(url string) (messaging.Publisher, error) {
|
||||
conn, err := amqp.Dial(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -55,7 +47,6 @@ func (pub *publisher) Publish(topic string, msg messaging.Message) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
subject := fmt.Sprintf("%s.%s", chansPrefix, topic)
|
||||
if msg.Subtopic != "" {
|
||||
subject = fmt.Sprintf("%s.%s", subject, msg.Subtopic)
|
||||
@ -79,6 +70,6 @@ func (pub *publisher) Publish(topic string, msg messaging.Message) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pub *publisher) Close() {
|
||||
pub.conn.Close()
|
||||
func (pub *publisher) Close() error {
|
||||
return pub.conn.Close()
|
||||
}
|
||||
|
@ -30,13 +30,6 @@ var (
|
||||
|
||||
var _ messaging.PubSub = (*pubsub)(nil)
|
||||
|
||||
// PubSub wraps messaging Publisher exposing
|
||||
// Close() method for RabbitMQ connection.
|
||||
type PubSub interface {
|
||||
messaging.PubSub
|
||||
Close()
|
||||
}
|
||||
|
||||
type subscription struct {
|
||||
cancel func() error
|
||||
}
|
||||
@ -48,9 +41,8 @@ type pubsub struct {
|
||||
}
|
||||
|
||||
// NewPubSub returns RabbitMQ message publisher/subscriber.
|
||||
func NewPubSub(url, queue string, logger log.Logger) (PubSub, error) {
|
||||
endpoint := fmt.Sprintf("amqp://%s", url)
|
||||
conn, err := amqp.Dial(endpoint)
|
||||
func NewPubSub(url, queue string, logger log.Logger) (messaging.PubSub, error) {
|
||||
conn, err := amqp.Dial(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -28,13 +28,13 @@ func TestMain(m *testing.M) {
|
||||
log.Fatalf("Could not connect to docker: %s", err)
|
||||
}
|
||||
|
||||
container, err := pool.Run("rabbitmq", "3.9.10", []string{})
|
||||
container, err := pool.Run("rabbitmq", "3.9.20", []string{})
|
||||
if err != nil {
|
||||
log.Fatalf("Could not start container: %s", err)
|
||||
}
|
||||
handleInterrupt(pool, container)
|
||||
|
||||
address := fmt.Sprintf("%s:%s", "localhost", container.GetPort("5672/tcp"))
|
||||
address := fmt.Sprintf("amqp://%s:%s", "localhost", container.GetPort("5672/tcp"))
|
||||
if err := pool.Retry(func() error {
|
||||
publisher, err = rabbitmq.NewPublisher(address)
|
||||
return err
|
||||
|
@ -64,6 +64,8 @@ setup_mf() {
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
echo "Compile check for rabbitmq..."
|
||||
MF_BROKER_TYPE=rabbitmq make http
|
||||
make -j$NPROC
|
||||
}
|
||||
|
||||
|
@ -22,12 +22,12 @@ default values.
|
||||
| MF_TWINS_DB | Database name | mainflux |
|
||||
| MF_TWINS_DB_HOST | Database host address | localhost |
|
||||
| MF_TWINS_DB_PORT | Database host port | 27017 |
|
||||
| MF_THINGS_STANDALONE_EMAIL | User email for standalone mode (no gRPC communication with users) | |
|
||||
| MF_THINGS_STANDALONE_TOKEN | User token for standalone mode that should be passed in auth header | |
|
||||
| MF_THINGS_STANDALONE_EMAIL | User email for standalone mode (no gRPC communication with users) | |
|
||||
| MF_THINGS_STANDALONE_TOKEN | User token for standalone mode that should be passed in auth header | |
|
||||
| MF_TWINS_CLIENT_TLS | Flag that indicates if TLS should be turned on | false |
|
||||
| MF_TWINS_CA_CERTS | Path to trusted CAs in PEM format | |
|
||||
| MF_TWINS_CHANNEL_ID | NATS notifications channel ID | |
|
||||
| MF_NATS_URL | Mainflux NATS broker URL | nats://localhost:4222 |
|
||||
| MF_TWINS_CHANNEL_ID | Message broker notifications channel ID | |
|
||||
| MF_BROKER_URL | Mainflux Message broker URL | nats://localhost:4222 |
|
||||
| MF_AUTH_GRPC_URL | Auth service gRPC URL | localhost:8181 |
|
||||
| MF_AUTH_GRPC_TIMEOUT | Auth service gRPC request timeout in seconds | 1s |
|
||||
| MF_TWINS_CACHE_URL | Cache database URL | localhost:6379 |
|
||||
@ -67,8 +67,8 @@ MF_THINGS_STANDALONE_EMAIL=[User email for standalone mode (no gRPC communicatio
|
||||
MF_THINGS_STANDALONE_TOKEN=[User token for standalone mode that should be passed in auth header] \
|
||||
MF_TWINS_CLIENT_TLS: [Flag that indicates if TLS should be turned on] \
|
||||
MF_TWINS_CA_CERTS: [Path to trusted CAs in PEM format] \
|
||||
MF_TWINS_CHANNEL_ID: [NATS notifications channel ID] \
|
||||
MF_NATS_URL: [Mainflux NATS broker URL] \
|
||||
MF_TWINS_CHANNEL_ID: [Message broker notifications channel ID] \
|
||||
MF_BROKER_URL: [Mainflux Message broker URL] \
|
||||
MF_AUTH_GRPC_URL: [Auth service gRPC URL] \
|
||||
MF_AUTH_GRPC_TIMEOUT: [Auth service gRPC request timeout in seconds] \
|
||||
$GOBIN/mainflux-twins
|
||||
@ -78,7 +78,7 @@ $GOBIN/mainflux-twins
|
||||
|
||||
### Starting twins service
|
||||
|
||||
The twins service publishes notifications on a NATS subject of the format
|
||||
The twins service publishes notifications on a Message broker subject of the format
|
||||
`channels.<MF_TWINS_CHANNEL_ID>.messages.<twinID>.<crudOp>`, where `crudOp`
|
||||
stands for the crud operation done on twin - create, update, delete or
|
||||
retrieve - or state - save state. In order to use twin service notifications,
|
||||
|
@ -27,3 +27,7 @@ func (mb mockBroker) Publish(topic string, msg messaging.Message) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mb mockBroker) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
@ -422,6 +422,6 @@ func (ts *twinsService) publish(twinID *string, err *error, succOp, failOp strin
|
||||
}
|
||||
|
||||
if err := ts.publisher.Publish(msg.Channel, msg); err != nil {
|
||||
ts.logger.Warn(fmt.Sprintf("Failed to publish notification on NATS: %s", err))
|
||||
ts.logger.Warn(fmt.Sprintf("Failed to publish notification on Message Broker: %s", err))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user