DS Service Registry Admin Guide
Configuration
The Service Registry is realised using LinkSmart Service Catalog (SC). SC is configured using a JSON configuration file, path to which is provided to the SC via -conf
flag. By default, the service looks for a configuration file at: conf/service-catalog.json
All configuration fields (except for arrays of objects) can be overridden using environment variables. Below are few examples:
SC_STORAGE_TYPE=leveldb
SC_MQTT_CLIENT_BROKERURI=tcp://iot.linksmart.eu:1883
SC_MQTT_CLIENT_REGTOPICS="a/b,a/c"
- ❌
SC_MQTT_ADDITIONALCLIENTS
setting array of objects is not supported with environment variables
Configuration File
A sample configuration file is available at service-catalog.json.
{
"description": "string",
"dnssdEnabled": "boolean",
"storage": {
"type": "string",
"dsn": "string"
},
"http" : {
"bindAddr": "string",
"bindPort": "int"
},
"mqtt":{
"client": {
"disabled": "bool",
"brokerID": "string",
"brokerURI":"string",
"regTopics": ["string"],
"willTopics": ["string"],
"qos": "int",
"username": "",
"password": ""
},
"additionalClients": [],
"commonRegTopics": ["string"],
"commonWillTopics": ["string"],
"topicPrefix": "string"
},
"auth": {
"enabled": "bool",
"provider": "string",
"providerURL": "string",
"serviceID": "string",
"basicEnabled": "bool",
"authorization": {}
}
}
where
description
is a human-readable description for the SCdnssdEnabled
is a flag enabling DNS-SD advertisement of the catalog on the networkstorage
is the configuration of the storage backendtype
is the type of the backend (supported backends arememory
andleveldb
)dsn
is the Data Source Name for storage backend (ignored formemory
, “ file:///path/to/ldb” forleveldb
)
http
is the configuration of HTTP APIbindAddr
is the bind address which the server listens onbindPort
is the bind port
mqtt
is the configuration of MQTT APIclient
is the configuration for the main MQTT clientdisabled
is a boolean flag disabling/enabling the mqtt clientbrokerID
is the service ID of the broker (Optional)brokerURI
is the URL of the brokerregTopics
is an array of topics that the client should subscribe to for addition/update of services- Example:
"regTopics": ["topic/reg/+"]
- While publishing a service registration message over this topic, ‘+’ should be replaced by id of the service to be added/updated. id passed in message payload takes precedence over id in the topic
- E.g.,
mosquitto_pub -h localhost -p 1883 -t 'topic/reg/custom_id1' -f ./service_object.json
- E.g.,
- Example:
willTopics
is an array of will topics that the client should subscribe to for removal of services (Optional in case TTL is used for registration)- Example:
"willTopics": ["topic/dereg/+"]
- While publishing a service deregistration message over this topic, ‘+’ should be replaced by id of the service to be removed
- E.g.,
mosquitto_pub -h localhost -p 1883 -t 'topic/dereg/custom_id1' -m 'something'
- E.g.,
- Example:
qos
is the MQTT Quality of Service (QoS) for all reg and will topicsusername
is username for MQTT clientpassword
is the password for MQTT client
additionalClients
is an array of additionalbrokers
objects.commonRegTopics
is an array of topics that all clients should subscribe to for addition/update of services (Optional)- Example: same as the example for ‘regTopics’ above
commonWillTopics
is an array of will topic that the client should subscribe to for removal of services (Optional in casecommonRegTopics
not used or TTL is used for registration)- Example: same as the example for ‘willTopics’ above
**topicPrefix**
is the string describing the prefix of service announcement topics
auth
is the Authentication configurationenabled
is a boolean flag enabling/disabling the authenticationprovider
is the name of a supported auth providerproviderURL
is the URL of the auth provider endpointserviceID
is the ID of the service in the authentication provider (used for validating auth tokens provided by the clients)basicEnabled
is a boolean flag enabling/disabling the Basic Authenticationauthorization
- optional, see authorization configuation
Deployment
Docker
docker run -d --name sr -p 8082:8082 linksmart/sc
The index of the REST API should now be accessible at: http://localhost:8082
Custom configuration
For a configuration file located on host at $(pwd)/conf/service-catalog.json
docker run -p 8082:8082 --name serviceregistry -d -v $(pwd)/conf:/conf -v $(pwd)/data:/data --restart=unless-stopped linksmart/sc:latest -conf /conf/service-catalog.json
Binary Distributions
Available for released versions and for multiple platforms: https://github.com/linksmart/service-catalog/releases
Download and run:
./service-catalog-<os-arch> --help
On Linux and macOS, it needs to have execution permission. E.g. chmod +x service-catalog-<os-arch>