maestroConfig

package
v2.10.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const INCREASED_DEVICEDB_STATUS_CHECK_INTERVAL_IN_SECS int = 120 //Exponential retry backoff interval
View Source
const INITIAL_DEVICEDB_STATUS_CHECK_INTERVAL_IN_SECS int = 5 //5 secs
View Source
const LOOP_WAIT_TIME_INCREMENT_WINDOW int = (6 * 60) //6 minutes which is the exponential retry backoff window
View Source
const MAX_DEVICEDB_WAIT_TIME_IN_SECS int = (24 * 60 * 60) //24 hours

Constants used in the logic for connecting to devicedb

Variables

This section is empty.

Functions

func ConfigGetMinDiskSpaceScratch

func ConfigGetMinDiskSpaceScratch() uint64

func ConvertLevelStringToUint32Mask

func ConvertLevelStringToUint32Mask(levels string) uint32

@param levels is a string of one or more comma separated value for levels, like: "warn, error"

func ConvertLevelUint32MaskToString

func ConvertLevelUint32MaskToString(mask uint32) string

func ConvertTagStringToUint32

func ConvertTagStringToUint32(tag string) uint32

func ConvertTagUint32ToString

func ConvertTagUint32ToString(tag uint32) string

func GetGlobalConfigDictionary

func GetGlobalConfigDictionary() (ret *templates.TemplateVarDictionary)

func GetInterpolatedConfigString

func GetInterpolatedConfigString(s string) string

replaces the {{VAR}} macro strings with their appropriate names values Currently the config files supports: {{thisdir}} - the directory where the maestro exec resides {{cwd}} the 'current working directory' of the Maestro process

Types

type Config

type Config interface {
	Get(t interface{}) error
	Put(t interface{}) error
	Delete() error
	Watch() Watcher
}

Config interface provides the means for client to get the specified config, and also could watch the updates about the config.

type ConfigError

type ConfigError struct {
	// contains filtered or unexported fields
}

ConfigError is the error type when there is an issue in the config parsing

func (*ConfigError) Error

func (err *ConfigError) Error() string

Error implements error.Error

type ConfigWrapper

type ConfigWrapper struct {
	Name  string      `json:"name"`
	Relay string      `json:"relay"`
	Body  interface{} `json:"body"`
}

Generic wrapper for storing the config structs

type DDBConfig

type DDBConfig struct {
	Key          string
	Bucket       string
	ConfigClient *DDBRelayConfigClient
}

DDBConfig has the name of the config and also include the instance of DDBRelayConfigClient, which is used by the implementation of the Config interface

func (*DDBConfig) Delete

func (ddbConfig *DDBConfig) Delete() (err error)

Delete function will remove the config object with the configName in ddbConfig object

func (*DDBConfig) DeviceDBKey

func (ddbConfig *DDBConfig) DeviceDBKey() string

get the devicedb key used for this config monitor

func (*DDBConfig) Get

func (ddbConfig *DDBConfig) Get(t interface{}) (err error)

Get function will get the config with the expecting format and fill it into the parameter t. It will return nil error when there is no such config exists or the config value could be parsed as the format that client specified, otherwise it will return false when the config value could not be parsed as expecting format

func (*DDBConfig) Put

func (ddbConfig *DDBConfig) Put(t interface{}) (err error)

Put function will write the passed config object(t) with the configName in ddbConfig object

func (*DDBConfig) Watch

func (ddbConfig *DDBConfig) Watch() Watcher

Watch will register a watcher for the client to monitor the updates about the given config

type DDBRelayConfigClient

type DDBRelayConfigClient struct {
	Uri    string
	Relay  string
	Bucket string
	Prefix string
	Client client_relay.Client
}

DDBRelayConfigClient specifies some attributes for devicedb server that use to setup the client

func CreateDDBRelayConfigClient

func CreateDDBRelayConfigClient(ddbConnConfig *DeviceDBConnConfig) (*DDBRelayConfigClient, error)

This function is called during bootup. It waits for devicedb to be up and running to connect to it

func GetDDBRelayConfigClient

func GetDDBRelayConfigClient(ddbConnConfig *DeviceDBConnConfig) (*DDBRelayConfigClient, error)

This function creates and returns a singleton DDBRelayConfigClient

func NewDDBRelayConfigClient

func NewDDBRelayConfigClient(tlsConfig *tls.Config, uri string, relay string, prefix string, bucket string) *DDBRelayConfigClient

NewDDBRelayConfigClient will initialize an client from devicedb/client_relay, and it will setup an instance of DDBRelayConfigClient

func (*DDBRelayConfigClient) AddMonitorConfig

func (this *DDBRelayConfigClient) AddMonitorConfig(config interface{}, updatedConfig interface{}, configName string, configAnalyzer *maestroSpecs.ConfigAnalyzer) (err error)

This function is used to add a configuration monitor for the "config" object with name "configName". configAnalyzer object is used for comparing new and old config objects which is used by the monitor when it detects a config object change

func (*DDBRelayConfigClient) Config

func (ddbClient *DDBRelayConfigClient) Config(name string) Config

Config return a config instance which is a monitoring client that specified by the given config name

func (*DDBRelayConfigClient) IsAvailable

func (rcc *DDBRelayConfigClient) IsAvailable() bool

func (*DDBRelayConfigClient) RemoveMonitorConfig

func (this *DDBRelayConfigClient) RemoveMonitorConfig(configName string) (err error)

This function is used to delete a configuration monitor with name "configName".

type DDBWatcher

type DDBWatcher struct {
	Updates chan string
	Config  *DDBConfig
	// contains filtered or unexported fields
}

DDBWatcher provides a channel that process the updates, and the config could be used while handling the updates from devicedb

func (*DDBWatcher) Next

func (watcher *DDBWatcher) Next(t interface{}) bool

Next would parse the config as the given interface and return true when the configuration with given key still exists, otherwise it will return false

func (*DDBWatcher) Run

func (watcher *DDBWatcher) Run()

Run will start the go routine that handle the updates from the monitoring config value or errors from the devicedb

func (*DDBWatcher) Stop

func (watcher *DDBWatcher) Stop()

Stop will stop the handleWatched go routine in preparation for removing this watcher

type DebugOptions

type DebugOptions struct {
	// PidFile if provided will write a file with the current PID
	PidFile string `yaml:"pid_file"`
	// KeepPids if true, will append the PID number instead of truncate and write
	KeepPids bool `yaml:"keep_pids"`
	// PidFileDara prints the current date/time next to the pid number in the file upod pid file creation
	PidFileDates bool `yaml:"pid_file_dates"`
}

type DeviceDBConnConfig

type DeviceDBConnConfig struct {
	// The URI of the relay's local DeviceDB instance
	DeviceDBUri string `yaml:"devicedb_uri"`
	// The prefix where keys related to configuration are stored
	DeviceDBPrefix string `yaml:"devicedb_prefix"`
	// The devicedb bucket where configurations are stored
	DeviceDBBucket string `yaml:"devicedb_bucket"`
	// The ID of the relay whose configuration should be monitored
	RelayId string `yaml:"relay_id"`
	// The file path to a PEM encoded CA chain used to validate the server certificate used by the DeviceDB instance
	CaChainCert string `yaml:"ca_chain"`
}

type GatewayResource

type GatewayResource struct {
	Name           string `yaml:"name"`
	Enable         bool   `yaml:"enable"`
	ConfigFilePath string `yaml:"config_filepath"`
}

type GcdConfig

type GcdConfig struct {
	EdgeCoreSocketPath string            `yaml:"edge_core_socketpath"`
	ConfigObjectId     int               `yaml:"lwm2m_objectid"`
	GatewayResources   []GatewayResource `yaml:"gateway_resources"`
}

type MdnsSetup

type MdnsSetup struct {
	Disable       bool                `yaml:"disable"`
	StaticRecords []*mdns.ConfigEntry `yaml:"static_records"`
}

type PlatformReader

type PlatformReader struct {
	Platform string `yaml:"platform"`
	// Opts is an optional PluginOpts config
	Opts   *maestroSpecs.PluginOpts `yaml:"opts"`
	Params map[string]interface{}   `yaml:"params,omitempty"`
}

type Plugin

type Plugin struct {
	// Id is an identifier used to call out this generic plugin in the
	// logging system and in errors. Generic plugins are plugins which are
	// not a platform or watchdog plugin. Id is like a name
	ID string `yaml:"id"`
	// A path to the plugin .so file
	Path string `yaml:"path"`
	// Opts is an optional PluginOpts config
	Opts *maestroSpecs.PluginOpts `yaml:"opts"`
}

type RelayConfigClient

type RelayConfigClient interface {
	Config(n string) Config
}

RelayConfigClient will be used by a gateway program. It will provide a client to monitor the relative configuration file.

type StaticFileOp

type StaticFileOp struct {
	Name           string `yaml:"name"`
	TemplateFile   string `yaml:"template_file"`
	TemplateString string `yaml:"template"`
	OutputFile     string `yaml:"output_file"`
}

type SubstVars

type SubstVars struct {
	Key   string `yaml:"key"`
	Value string `yaml:"value"`
}

type Watcher

type Watcher interface {
	// Run would start the go routine that handles the updates about the monitoring config
	Run()

	// Stop would stop the go routine that handles the updates about the monitoring config
	Stop()

	// Next would parse the config as the given interface and return true when the
	// configuration with given key still exists, otherwise it will return false
	Next(t interface{}) bool
}

Watcher interface lets the client could use it to run the monitor, receive the updates about the config and parse it as expected format

type YAMLMaestroConfig

type YAMLMaestroConfig struct {
	UnixLogSocket        string `yaml:"unixLogSocket"`
	SyslogSocket         string `yaml:"sysLogSocket"`
	LinuxKernelLog       bool   `yaml:"linuxKernelLog"`
	LinuxKernelLogLegacy bool   `yaml:"linuxKernelLogLegacy"`
	//	ApiUnixDgramSocket string `yaml:"apiUnixDgramSocket"` // not used yet
	HttpUnixSocket       string                                  `yaml:"httpUnixSocket"`
	VarDefs              []SubstVars                             `yaml:"var_defs"`
	TimeServer           *time.ClientConfig                      `yaml:"time_server"`
	Mdns                 *MdnsSetup                              `yaml:"mdns"`
	Watchdog             *maestroSpecs.WatchdogConfig            `yaml:"watchdog"`
	Symphony             *wwrmi.ClientConfig                     `yaml:"symphony"`
	SysStats             *sysstats.StatsConfig                   `yaml:"sys_stats"`
	Tags                 []string                                `yaml:"tags"`
	Targets              []maestroSpecs.LogTarget                `yaml:"targets"`
	ClientId             string                                  `yaml:"clientId"`
	ConfigDBPath         string                                  `yaml:"configDBPath"` // where Maestro should look for it's database
	Stats                maestroSpecs.StatsConfigPayload         `yaml:"stats"`
	JobStarts            []maestroSpecs.JobDefinitionPayload     `yaml:"jobs"`
	ContainerTemplates   []maestroSpecs.ContainerTemplatePayload `yaml:"container_templates"`
	ImagePath            string                                  `yaml:"imagePath"`   // where we should place Job images
	ScratchPath          string                                  `yaml:"scratchPath"` // where we should place temporary file, downloads, etc.
	StaticFileGenerators []StaticFileOp                          `yaml:"static_file_generators"`
	PlatformReaders      []PlatformReader                        `yaml:"platform_readers"`
	Plugins              []Plugin                                `yaml:"plugins"`
	Network              *maestroSpecs.NetworkConfigPayload      `yaml:"network"`
	GatewayCapabilities  *GcdConfig                              `yaml:"gateway_capabilities"`
	Processes            *configs.ProcessesConfig                `yaml:"processes"`
	DebugOpts            *DebugOptions                           `yaml:"debug_opts"`
	DDBConnConfig        *DeviceDBConnConfig                     `yaml:"devicedb_conn_config"`
	ConfigEnd            bool                                    `yaml:"config_end"`
}

func (*YAMLMaestroConfig) FillInDefaults

func (ysc *YAMLMaestroConfig) FillInDefaults()

FillInDefaults goes through specific parts of the config and puts in defaults if strings were missing or empty.

func (*YAMLMaestroConfig) FinalizeConfig

func (ysc *YAMLMaestroConfig) FinalizeConfig()

FinalizeConfig Interpolates all config strings and fills in defaults

func (*YAMLMaestroConfig) GetDBPath

func (ysc *YAMLMaestroConfig) GetDBPath() (ret string)

func (*YAMLMaestroConfig) GetHttpUnixSocket

func (ysc *YAMLMaestroConfig) GetHttpUnixSocket() (ret string)

func (*YAMLMaestroConfig) GetImagePath

func (ysc *YAMLMaestroConfig) GetImagePath() (ret string)

func (*YAMLMaestroConfig) GetScratchPath

func (ysc *YAMLMaestroConfig) GetScratchPath() (ret string)

func (*YAMLMaestroConfig) GetSyslogSocket

func (ysc *YAMLMaestroConfig) GetSyslogSocket() (ret string)

func (*YAMLMaestroConfig) GetUnixLogSocket

func (ysc *YAMLMaestroConfig) GetUnixLogSocket() (ret string)

func (*YAMLMaestroConfig) InterpolateAllStrings

func (ysc *YAMLMaestroConfig) InterpolateAllStrings()

func (*YAMLMaestroConfig) LoadFromFile

func (ysc *YAMLMaestroConfig) LoadFromFile(file string) error

LoadFromFile load the config file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL