-
Notifications
You must be signed in to change notification settings - Fork 1
Services
Services are plugins designed to extend the functionality of Casa. Almost everything Casa does is run as a service to enable flexibility for the user.
A Casa service need only implement the following three functions:
Start(config *viper.Viper) error
UseLogger(logger Logger)
Stop() error
-
Start(config *viper.Viper) error: This is the main part of the service, where it is configured and then started.configis an in-memory representation of the section of configuration file for the service. For example theServices.Loggerportion of the config file is passed to theloggerservice whenStart()is called. Anerroris returned if there is any problem starting the service. -
UseLogger(logger Logger): This specifies the logger to be used for debugging output. It allows the use of a single logger throughout the entire program. -
Stop() error: This stops the service and returns anerrorif there were any issues in doing so.
Services are responsible for creating their own MQTT client and connecting to the MessageBus. By default, services can connect to tcp://127.0.0.1:1883 with no SSL or other authentication. If the user were to specify one or more username/password combinations for outside devices to connect to the MessageBus, then a random username/password combination will be generated and passed to the service when Start() is called. They will be available in config as MQTT.User and MQTT.Pass.