NOISSUE - Refactor Redis URI (#1898)

* Replace Nats with Nats Jestream For PubSub

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>

* Refactor Redis client connection

Use a single Redis URI to connect to Redis where the URI contains
host, port, database and possibly username and password.

This is to simplify environment variable configuration.

Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>

---------

Signed-off-by: rodneyosodo <blackd0t@protonmail.com>
Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
Signed-off-by: Rodney Osodo <28790446+rodneyosodo@users.noreply.github.com>
This commit is contained in:
b1ackd0t 2023-10-23 18:25:57 +03:00 committed by GitHub
parent 9b4c2b24c8
commit 059b954047
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 99 additions and 171 deletions

View File

@ -35,10 +35,9 @@ import (
)
const (
svcName = "lora-adapter"
envPrefixHTTP = "MF_LORA_ADAPTER_HTTP_"
envPrefixRouteMap = "MF_LORA_ADAPTER_ROUTE_MAP_"
defSvcHTTPPort = "9017"
svcName = "lora-adapter"
envPrefixHTTP = "MF_LORA_ADAPTER_HTTP_"
defSvcHTTPPort = "9017"
thingsRMPrefix = "thing"
channelsRMPrefix = "channel"
@ -59,6 +58,7 @@ type config struct {
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`
InstanceID string `env:"MF_LORA_ADAPTER_INSTANCE_ID" envDefault:""`
ESURL string `env:"MF_LORA_ADAPTER_ES_URL" envDefault:"redis://localhost:6379/0"`
RouteMapURL string `env:"MF_LORA_ADAPTER_ROUTE_MAP_URL" envDefault:"redis://localhost:6379/0"`
}
func main() {
@ -93,7 +93,7 @@ func main() {
return
}
rmConn, err := redisclient.Setup(envPrefixRouteMap)
rmConn, err := redisclient.Connect(cfg.RouteMapURL)
if err != nil {
logger.Error(fmt.Sprintf("failed to setup route map redis client : %s", err))
exitCode = 1

View File

@ -33,10 +33,9 @@ import (
)
const (
svcName = "opc-ua-adapter"
envPrefixHTTP = "MF_OPCUA_ADAPTER_HTTP_"
envPrefixRouteMap = "MF_OPCUA_ADAPTER_ROUTE_MAP_"
defSvcHTTPPort = "8180"
svcName = "opc-ua-adapter"
envPrefixHTTP = "MF_OPCUA_ADAPTER_HTTP_"
defSvcHTTPPort = "8180"
thingsRMPrefix = "thing"
channelsRMPrefix = "channel"
@ -53,6 +52,7 @@ type config struct {
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`
InstanceID string `env:"MF_OPCUA_ADAPTER_INSTANCE_ID" envDefault:""`
ESURL string `env:"MF_OPCUA_ADAPTER_ES_URL" envDefault:"redis://localhost:6379/0"`
RouteMapURL string `env:"MF_OPCUA_ADAPTER_ROUTE_MAP_URL" envDefault:"redis://localhost:6379/0"`
}
func main() {
@ -92,7 +92,7 @@ func main() {
return
}
rmConn, err := redisclient.Setup(envPrefixRouteMap)
rmConn, err := redisclient.Connect(cfg.RouteMapURL)
if err != nil {
logger.Error(fmt.Sprintf("failed to setup %s bootstrap event store redis client : %s", svcName, err))
exitCode = 1

View File

@ -51,8 +51,6 @@ import (
const (
svcName = "things"
envPrefixDB = "MF_THINGS_DB_"
envPrefixCache = "MF_THINGS_CACHE_"
envPrefixES = "MF_THINGS_ES_"
envPrefixHTTP = "MF_THINGS_HTTP_"
envPrefixGRPC = "MF_THINGS_AUTH_GRPC_"
defDB = "things"
@ -67,8 +65,9 @@ type config struct {
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"http://jaeger:14268/api/traces"`
CacheKeyDuration string `env:"MF_THINGS_CACHE_KEY_DURATION" envDefault:"10m"`
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`
InstanceID string `env:"MF_THINGS_INSTANCE_ID" envDefault:""`
InstanceID string `env:"MF_THINGS_INSTANCE_ID" envDefault:""`
ESURL string `env:"MF_THINGS_ES_URL" envDefault:"redis://localhost:6379/0"`
CacheURL string `env:"MF_THINGS_CACHE_URL" envDefault:"redis://localhost:6379/0"`
}
func main() {
@ -128,7 +127,7 @@ func main() {
tracer := tp.Tracer(svcName)
// Setup new redis cache client
cacheclient, err := redisclient.Setup(envPrefixCache)
cacheclient, err := redisclient.Connect(cfg.CacheURL)
if err != nil {
logger.Error(err.Error())
exitCode = 1
@ -136,15 +135,6 @@ func main() {
}
defer cacheclient.Close()
// Setup new redis event store client
esclient, err := redisclient.Setup(envPrefixES)
if err != nil {
logger.Error(err.Error())
exitCode = 1
return
}
defer esclient.Close()
var auth mainflux.AuthServiceClient
switch cfg.StandaloneID != "" && cfg.StandaloneToken != "" {
@ -163,7 +153,7 @@ func main() {
logger.Info("Successfully connected to auth grpc server " + authHandler.Secure())
}
csvc, gsvc, err := newService(ctx, db, dbConfig, auth, cacheclient, esclient, cfg.CacheKeyDuration, cfg.ESURL, tracer, logger)
csvc, gsvc, err := newService(ctx, db, dbConfig, auth, cacheclient, cfg.CacheKeyDuration, cfg.ESURL, tracer, logger)
if err != nil {
logger.Error(fmt.Sprintf("failed to create services: %s", err))
exitCode = 1
@ -214,7 +204,7 @@ func main() {
}
}
func newService(ctx context.Context, db *sqlx.DB, dbConfig pgclient.Config, auth mainflux.AuthServiceClient, cacheClient *redis.Client, esClient *redis.Client, keyDuration, esURL string, tracer trace.Tracer, logger mflog.Logger) (things.Service, groups.Service, error) {
func newService(ctx context.Context, db *sqlx.DB, dbConfig pgclient.Config, auth mainflux.AuthServiceClient, cacheClient *redis.Client, keyDuration, esURL string, tracer trace.Tracer, logger mflog.Logger) (things.Service, groups.Service, error) {
database := postgres.NewDatabase(db, dbConfig, tracer)
cRepo := thingspg.NewRepository(database)
gRepo := gpostgres.New(database)

View File

@ -42,7 +42,6 @@ const (
svcName = "twins"
envPrefixDB = "MF_TWINS_DB_"
envPrefixHTTP = "MF_TWINS_HTTP_"
envPrefixCache = "MF_TWINS_CACHE_"
defSvcHTTPPort = "9018"
)
@ -56,6 +55,7 @@ type config struct {
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`
InstanceID string `env:"MF_TWINS_INSTANCE_ID" envDefault:""`
ESURL string `env:"MF_TWINS_ES_URL" envDefault:"redis://localhost:6379/0"`
CacheURL string `env:"MF_TWINS_CACHE_URL" envDefault:"redis://localhost:6379/0"`
}
func main() {
@ -90,7 +90,7 @@ func main() {
return
}
cacheClient, err := redisclient.Setup(envPrefixCache)
cacheClient, err := redisclient.Connect(cfg.CacheURL)
if err != nil {
logger.Error(err.Error())
exitCode = 1

View File

@ -157,9 +157,7 @@ MF_THINGS_AUTH_GRPC_SERVER_CA_CERTS=${GRPC_MTLS:+./ssl/certs/ca.crt}${GRPC_TLS:+
MF_THINGS_ES_URL=es-redis:${MF_REDIS_TCP_PORT}
MF_THINGS_ES_PASS=
MF_THINGS_ES_DB=0
MF_THINGS_CACHE_URL=things-redis:${MF_REDIS_TCP_PORT}
MF_THINGS_CACHE_PASS=
MF_THINGS_CACHE_DB=0
MF_THINGS_CACHE_URL=redis://things-redis:${MF_REDIS_TCP_PORT}/0
MF_THINGS_DB_HOST=things-db
MF_THINGS_DB_PORT=5432
MF_THINGS_DB_USER=mainflux
@ -316,9 +314,7 @@ MF_LORA_ADAPTER_HTTP_HOST=lora-adapter
MF_LORA_ADAPTER_HTTP_PORT=9017
MF_LORA_ADAPTER_HTTP_SERVER_CERT=
MF_LORA_ADAPTER_HTTP_SERVER_KEY=
MF_LORA_ADAPTER_ROUTE_MAP_URL=lora-redis:${MF_REDIS_TCP_PORT}
MF_LORA_ADAPTER_ROUTE_MAP_PASS=
MF_LORA_ADAPTER_ROUTE_MAP_DB=0
MF_LORA_ADAPTER_ROUTE_MAP_URL=redis://lora-redis:${MF_REDIS_TCP_PORT}/0
MF_LORA_ADAPTER_INSTANCE_ID=
### OPC-UA
@ -331,9 +327,7 @@ MF_OPCUA_ADAPTER_HTTP_SERVER_KEY=
MF_OPCUA_ADAPTER_ES_URL=es-redis:${MF_REDIS_TCP_PORT}
MF_OPCUA_ADAPTER_ES_PASS=
MF_OPCUA_ADAPTER_ES_DB=0
MF_OPCUA_ADAPTER_ROUTE_MAP_URL=opcua-redis:${MF_REDIS_TCP_PORT}
MF_OPCUA_ADAPTER_ROUTE_MAP_PASS=
MF_OPCUA_ADAPTER_ROUTE_MAP_DB=0
MF_OPCUA_ADAPTER_ROUTE_MAP_URL=redis://opcua-redis:${MF_REDIS_TCP_PORT}/0
MF_OPCUA_ADAPTER_INSTANCE_ID=
### Cassandra
@ -482,9 +476,7 @@ MF_TWINS_HTTP_HOST=twins
MF_TWINS_HTTP_PORT=9018
MF_TWINS_HTTP_SERVER_CERT=
MF_TWINS_HTTP_SERVER_KEY=
MF_TWINS_CACHE_URL=twins-redis:${MF_REDIS_TCP_PORT}
MF_TWINS_CACHE_PASS=
MF_TWINS_CACHE_DB=0
MF_TWINS_CACHE_URL=redis://twins-redis:${MF_REDIS_TCP_PORT}/0
MF_THINGS_ES_URL=es-redis:${MF_REDIS_TCP_PORT}
MF_THINGS_ES_PASS=
MF_THINGS_ES_DB=0

View File

@ -35,9 +35,7 @@ services:
MF_LORA_ADAPTER_HTTP_PORT: ${MF_LORA_ADAPTER_HTTP_PORT}
MF_LORA_ADAPTER_HTTP_SERVER_CERT: ${MF_LORA_ADAPTER_HTTP_SERVER_CERT}
MF_LORA_ADAPTER_HTTP_SERVER_KEY: ${MF_LORA_ADAPTER_HTTP_SERVER_KEY}
MF_LORA_ADAPTER_ROUTE_MAP_URL: lora-redis:${MF_REDIS_TCP_PORT}
MF_LORA_ADAPTER_ROUTE_MAP_PASS: ${MF_LORA_ADAPTER_ROUTE_MAP_PASS}
MF_LORA_ADAPTER_ROUTE_MAP_DB: ${MF_LORA_ADAPTER_ROUTE_MAP_DB}
MF_LORA_ADAPTER_ROUTE_MAP_URL: ${MF_LORA_ADAPTER_ROUTE_MAP_URL}
MF_LORA_ADAPTER_ES_URL: ${MF_ES_URL}
MF_MESSAGE_BROKER_URL: ${MF_MESSAGE_BROKER_URL}
MF_JAEGER_URL: ${MF_JAEGER_URL}

View File

@ -38,8 +38,6 @@ services:
MF_OPCUA_ADAPTER_HTTP_SERVER_KEY: ${MF_OPCUA_ADAPTER_HTTP_SERVER_KEY}
MF_OPCUA_ADAPTER_ES_URL: ${MF_ES_URL}
MF_OPCUA_ADAPTER_ROUTE_MAP_URL: ${MF_OPCUA_ADAPTER_ROUTE_MAP_URL}
MF_OPCUA_ADAPTER_ROUTE_MAP_PASS: ${MF_OPCUA_ADAPTER_ROUTE_MAP_PASS}
MF_OPCUA_ADAPTER_ROUTE_MAP_DB: ${MF_OPCUA_ADAPTER_ROUTE_MAP_DB}
MF_MESSAGE_BROKER_URL: ${MF_MESSAGE_BROKER_URL}
MF_JAEGER_URL: ${MF_JAEGER_URL}
MF_SEND_TELEMETRY: ${MF_SEND_TELEMETRY}

View File

@ -52,8 +52,6 @@ services:
MF_TWINS_HTTP_SERVER_CERT: ${MF_TWINS_HTTP_SERVER_CERT}
MF_TWINS_HTTP_SERVER_KEY: ${MF_TWINS_HTTP_SERVER_KEY}
MF_TWINS_CACHE_URL: ${MF_TWINS_CACHE_URL}
MF_TWINS_CACHE_PASS: ${MF_TWINS_CACHE_PASS}
MF_TWINS_CACHE_DB: ${MF_TWINS_CACHE_DB}
MF_TWINS_ES_URL: ${MF_ES_URL}
MF_THINGS_STANDALONE_ID: ${MF_THINGS_STANDALONE_ID}
MF_THINGS_STANDALONE_TOKEN: ${MF_THINGS_STANDALONE_TOKEN}

View File

@ -192,8 +192,6 @@ services:
MF_THINGS_AUTH_GRPC_CLIENT_CA_CERTS: ${MF_THINGS_AUTH_GRPC_CLIENT_CA_CERTS:+/things-grpc-client-ca.crt}
MF_THINGS_ES_URL: ${MF_ES_URL}
MF_THINGS_CACHE_URL: ${MF_THINGS_CACHE_URL}
MF_THINGS_CACHE_PASS: ${MF_THINGS_CACHE_PASS}
MF_THINGS_CACHE_DB: ${MF_THINGS_CACHE_DB}
MF_THINGS_DB_HOST: ${MF_THINGS_DB_HOST}
MF_THINGS_DB_PORT: ${MF_THINGS_DB_PORT}
MF_THINGS_DB_USER: ${MF_THINGS_DB_USER}

View File

@ -3,49 +3,14 @@
package redis
import (
"strconv"
"github.com/go-redis/redis/v8"
"github.com/mainflux/mainflux/internal/env"
"github.com/mainflux/mainflux/pkg/errors"
)
var (
errConfig = errors.New("failed to load redis client configuration")
errConnect = errors.New("failed to connect to redis server")
)
// Config of RedisDB.
type Config struct {
URL string `env:"URL" envDefault:"localhost:6379"`
Pass string `env:"PASS" envDefault:""`
DB string `env:"DB" envDefault:"0"`
}
// Setup load configuration from environment, creates new RedisDB client and connect to RedisDB Server.
func Setup(prefix string) (*redis.Client, error) {
cfg := Config{}
if err := env.Parse(&cfg, env.Options{Prefix: prefix}); err != nil {
return nil, errors.Wrap(errConfig, err)
}
client, err := Connect(cfg)
if err != nil {
return nil, errors.Wrap(errConnect, err)
}
return client, nil
}
import "github.com/go-redis/redis/v8"
// Connect create new RedisDB client and connect to RedisDB server.
func Connect(cfg Config) (*redis.Client, error) {
db, err := strconv.Atoi(cfg.DB)
func Connect(url string) (*redis.Client, error) {
opts, err := redis.ParseURL(url)
if err != nil {
return nil, err
}
return redis.NewClient(&redis.Options{
Addr: cfg.URL,
Password: cfg.Pass,
DB: db,
}), nil
return redis.NewClient(opts), nil
}

View File

@ -1,4 +1,5 @@
# LoRa Adapter
Adapter between Mainflux IoT system and [LoRa Server](https://github.com/brocaar/chirpstack-network-server).
This adapter sits between Mainflux and LoRa Server and just forwards the messages from one system to another via MQTT protocol, using the adequate MQTT topics and in the good message format (JSON and SenML), i.e. respecting the APIs of both systems.
@ -11,25 +12,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_LORA_ADAPTER_HTTP_PORT | Service HTTP port | 9017 |
| MF_LORA_ADAPTER_LOG_LEVEL | Service Log level | info |
| MF_MESSAGE_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 | |
| MF_LORA_ADAPTER_MESSAGES_PASS | LoRa adapter MQTT subscriber Password | |
| MF_LORA_ADAPTER_MESSAGES_TIMEOUT | LoRa adapter MQTT subscriber Timeout | 30s |
| MF_LORA_ADAPTER_ROUTE_MAP_URL | Route-map database URL | localhost:6379 |
| MF_LORA_ADAPTER_ROUTE_MAP_PASS | Route-map database password | |
| MF_LORA_ADAPTER_ROUTE_MAP_DB | Route-map instance | 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_LORA_ADAPTER_EVENT_CONSUMER | Service event consumer name | lora |
| MF_JAEGER_URL | Jaeger server URL | http://jaeger:14268/api/traces |
| MF_SEND_TELEMETRY | Send telemetry to mainflux call home server | true |
| Variable | Description | Default |
| -------------------------------- | ------------------------------------------- | ------------------------------- |
| MF_LORA_ADAPTER_HTTP_PORT | Service HTTP port | 9017 |
| MF_LORA_ADAPTER_LOG_LEVEL | Service Log level | info |
| MF_MESSAGE_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 | |
| MF_LORA_ADAPTER_MESSAGES_PASS | LoRa adapter MQTT subscriber Password | |
| MF_LORA_ADAPTER_MESSAGES_TIMEOUT | LoRa adapter MQTT subscriber Timeout | 30s |
| MF_LORA_ADAPTER_ROUTE_MAP_URL | Route-map database URL | redis://localhost:6379 |
| 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_LORA_ADAPTER_EVENT_CONSUMER | Service event consumer name | lora |
| MF_JAEGER_URL | Jaeger server URL | http://jaeger:14268/api/traces |
| MF_SEND_TELEMETRY | Send telemetry to mainflux call home server | true |
## Deployment
@ -59,8 +58,6 @@ MF_LORA_ADAPTER_MESSAGES_USER=[LoRa adapter MQTT subscriber Username] \
MF_LORA_ADAPTER_MESSAGES_PASS=[LoRa adapter MQTT subscriber Password] \
MF_LORA_ADAPTER_MESSAGES_TIMEOUT=[LoRa adapter MQTT subscriber Timeout]
MF_LORA_ADAPTER_ROUTE_MAP_URL=[Lora adapter routemap URL] \
MF_LORA_ADAPTER_ROUTE_MAP_PASS=[Lora adapter routemap password] \
MF_LORA_ADAPTER_ROUTE_MAP_DB=[Lora adapter routemap instance] \
MF_THINGS_ES_URL=[Things service event source URL] \
MF_THINGS_ES_PASS=[Things service event source password] \
MF_THINGS_ES_DB=[Things service event source password] \

View File

@ -1,4 +1,5 @@
# OPC-UA Adapter
Adapter between Mainflux IoT system and an OPC-UA Server.
This adapter sits between Mainflux and an OPC-UA server and just forwards the messages from one system to another.
@ -11,29 +12,27 @@ 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 | info |
| MF_MESSAGE_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 |
| MF_JAEGER_URL | Jaeger server URL | http://jaeger:14268/api/traces |
| MF_SEND_TELEMETRY | Send telemetry to mainflux call home server | true |
| Variable | Description | Default |
| ------------------------------- | ------------------------------------------- | ------------------------------ |
| MF_OPCUA_ADAPTER_HTTP_PORT | Service HTTP port | 8180 |
| MF_OPCUA_ADAPTER_LOG_LEVEL | Service Log level | info |
| MF_MESSAGE_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 | redis://localhost:6379/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 |
| MF_JAEGER_URL | Jaeger server URL | http://jaeger:14268/api/traces |
| MF_SEND_TELEMETRY | Send telemetry to mainflux call home server | true |
## Deployment
The service itself is distributed as Docker container. Check the [`opcua-adapter`](https://github.com/mainflux/mainflux/blob/master/docker/addons/opcua-adapter/docker-compose.yml#L29-L53) service section in
The service itself is distributed as Docker container. Check the [`opcua-adapter`](https://github.com/mainflux/mainflux/blob/master/docker/addons/opcua-adapter/docker-compose.yml#L29-L53) service section in
docker-compose to see how service is deployed.
To start the service outside of the container, execute the following shell script:
@ -60,8 +59,6 @@ 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] \
MF_OPCUA_ADAPTER_ROUTE_MAP_PASS=[Route-map database password] \
MF_OPCUA_ADAPTER_ROUTE_MAP_DB=[Route-map instance name] \
MF_THINGS_ES_URL=[Things service event source URL] \
MF_THINGS_ES_PASS=[Things service event source password] \
MF_THINGS_ES_DB=[Things service event source password] \

View File

@ -16,42 +16,40 @@ 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_THINGS_LOG_LEVEL | Log level for Things (debug, info, warn, error) | info |
| MF_THINGS_HTTP_HOST | Things service HTTP host | localhost |
| MF_THINGS_HTTP_PORT | Things service HTTP port | 9000 |
| MF_THINGS_SERVER_CERT | Path to the PEM encoded server certificate file | "" |
| MF_THINGS_SERVER_KEY | Path to the PEM encoded server key file | "" |
| MF_THINGS_AUTH_GRPC_HOST | Things service gRPC host | localhost |
| MF_THINGS_AUTH_GRPC_PORT | Things service gRPC port | 7000 |
| MF_THINGS_AUTH_GRPC_SERVER_CERT | Path to the PEM encoded server certificate file | "" |
| MF_THINGS_AUTH_GRPC_SERVER_KEY | Path to the PEM encoded server key file | "" |
| MF_THINGS_DB_HOST | Database host address | localhost |
| MF_THINGS_DB_PORT | Database host port | 5432 |
| MF_THINGS_DB_USER | Database user | mainflux |
| MF_THINGS_DB_PASS | Database password | mainflux |
| MF_THINGS_DB_NAME | Name of the database used by the service | things |
| MF_THINGS_DB_SSL_MODE | Database connection SSL mode (disable, require, verify-ca, verify-full) | disable |
| MF_THINGS_DB_SSL_CERT | Path to the PEM encoded certificate file | "" |
| MF_THINGS_DB_SSL_KEY | Path to the PEM encoded key file | "" |
| MF_THINGS_DB_SSL_ROOT_CERT | Path to the PEM encoded root certificate file | "" |
| MF_THINGS_CACHE_URL | Cache database URL | localhost:6379 |
| MF_THINGS_CACHE_PASS | Cache database password | "" |
| MF_THINGS_CACHE_DB | Cache instance name | 0 |
| MF_THINGS_CACHE_KEY_DURATION | Cache key duration in seconds | 3600 |
| MF_THINGS_ES_URL | Event store URL | localhost:6379 |
| MF_THINGS_ES_PASS | Event store password | "" |
| MF_THINGS_ES_DB | Event store instance name | 0 |
| MF_THINGS_STANDALONE_ID | User ID 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_JAEGER_URL | Jaeger server URL | http://jaeger:14268/api/traces |
| MF_AUTH_GRPC_URL | Users service gRPC URL | localhost:7001 |
| MF_AUTH_GRPC_TIMEOUT | Users service gRPC request timeout in seconds | 1s |
| MF_AUTH_GRPC_CLIENT_TLS | Enable TLS for gRPC client | false |
| MF_AUTH_GRPC_CA_CERT | Path to the CA certificate file | "" |
| MF_SEND_TELEMETRY | Send telemetry to mainflux call home server. | true |
| MF_THINGS_INSTANCE_ID | Things instance ID | "" |
| Variable | Description | Default |
| ------------------------------- | ----------------------------------------------------------------------- | ------------------------------ |
| MF_THINGS_LOG_LEVEL | Log level for Things (debug, info, warn, error) | info |
| MF_THINGS_HTTP_HOST | Things service HTTP host | localhost |
| MF_THINGS_HTTP_PORT | Things service HTTP port | 9000 |
| MF_THINGS_SERVER_CERT | Path to the PEM encoded server certificate file | "" |
| MF_THINGS_SERVER_KEY | Path to the PEM encoded server key file | "" |
| MF_THINGS_AUTH_GRPC_HOST | Things service gRPC host | localhost |
| MF_THINGS_AUTH_GRPC_PORT | Things service gRPC port | 7000 |
| MF_THINGS_AUTH_GRPC_SERVER_CERT | Path to the PEM encoded server certificate file | "" |
| MF_THINGS_AUTH_GRPC_SERVER_KEY | Path to the PEM encoded server key file | "" |
| MF_THINGS_DB_HOST | Database host address | localhost |
| MF_THINGS_DB_PORT | Database host port | 5432 |
| MF_THINGS_DB_USER | Database user | mainflux |
| MF_THINGS_DB_PASS | Database password | mainflux |
| MF_THINGS_DB_NAME | Name of the database used by the service | things |
| MF_THINGS_DB_SSL_MODE | Database connection SSL mode (disable, require, verify-ca, verify-full) | disable |
| MF_THINGS_DB_SSL_CERT | Path to the PEM encoded certificate file | "" |
| MF_THINGS_DB_SSL_KEY | Path to the PEM encoded key file | "" |
| MF_THINGS_DB_SSL_ROOT_CERT | Path to the PEM encoded root certificate file | "" |
| MF_THINGS_CACHE_URL | Cache database URL | redis://localhost:6379/0 |
| MF_THINGS_CACHE_KEY_DURATION | Cache key duration in seconds | 3600 |
| MF_THINGS_ES_URL | Event store URL | localhost:6379 |
| MF_THINGS_ES_PASS | Event store password | "" |
| MF_THINGS_ES_DB | Event store instance name | 0 |
| MF_THINGS_STANDALONE_ID | User ID 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_JAEGER_URL | Jaeger server URL | http://jaeger:14268/api/traces |
| MF_AUTH_GRPC_URL | Users service gRPC URL | localhost:7001 |
| MF_AUTH_GRPC_TIMEOUT | Users service gRPC request timeout in seconds | 1s |
| MF_AUTH_GRPC_CLIENT_TLS | Enable TLS for gRPC client | false |
| MF_AUTH_GRPC_CA_CERT | Path to the CA certificate file | "" |
| MF_SEND_TELEMETRY | Send telemetry to mainflux call home server. | true |
| MF_THINGS_INSTANCE_ID | Things instance ID | "" |
**Note** that if you want `thin gs` service to have only one user locally, you should use `MF_THINGS_STANDALONE` env vars. By specifying these, you don't need `auth` service in your deployment for users' authorization.
@ -97,8 +95,6 @@ MF_THINGS_DB_SSL_CERT=[Path to the PEM encoded certificate file] \
MF_THINGS_DB_SSL_KEY=[Path to the PEM encoded key file] \
MF_THINGS_DB_SSL_ROOT_CERT=[Path to the PEM encoded root certificate file] \
MF_THINGS_CACHE_URL=[Cache database URL] \
MF_THINGS_CACHE_PASS=[Cache database password] \
MF_THINGS_CACHE_DB=[Cache instance name] \
MF_THINGS_ES_URL=[Event store URL] \
MF_THINGS_ES_PASS=[Event store password] \
MF_THINGS_ES_DB=[Event store instance name] \

View File

@ -30,9 +30,7 @@ default values.
| MF_MESSAGE_BROKER_URL | Mainflux Message broker URL | nats://localhost:4222 |
| MF_AUTH_GRPC_URL | Users service gRPC URL | localhost:7001 |
| MF_AUTH_GRPC_TIMEOUT | Users service gRPC request timeout in seconds | 1s |
| MF_TWINS_CACHE_URL | Cache database URL | localhost:6379 |
| MF_TWINS_CACHE_PASS | Cache database password | |
| MF_TWINS_CACHE_DB | Cache instance name | 0 |
| MF_TWINS_CACHE_URL | Cache database URL | redis://localhost:6379/0 |
| MF_SEND_TELEMETRY | Send telemetry to mainflux call home server | true |
## Deployment
@ -72,6 +70,7 @@ MF_TWINS_CHANNEL_ID=[Message broker notifications channel ID] \
MF_MESSAGE_BROKER_URL=[Mainflux Message broker URL] \
MF_AUTH_GRPC_URL=[Users service gRPC URL] \
MF_AUTH_GRPC_TIMEOUT=[Users service gRPC request timeout in seconds] \
MF_TWINS_CACHE_URL=[Cache database URL] \
$GOBIN/mainflux-twins
```