configuration

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PluginsDir string

PluginsDir absolute path to service plugins directory

View Source
var WorkDir string

WorkDir absolute path to service working directory

Functions

func ConfigureLog

func ConfigureLog() error

func ConfigureLoggers

func ConfigureLoggers(c *LogConfig) error

func GetHumanLogger

func GetHumanLogger() *zap.SugaredLogger

GetHumanLogger return production logger

func GetLogger

func GetLogger() *zap.SugaredLogger

GetLogger return production logger

func LoadPlugins

func LoadPlugins(path string, list []string) map[string]PluginState

LoadPlugins load plugins from path

Types

type AcceptorConfig

type AcceptorConfig struct {
	MaxIncoming int `yaml:"maxIncoming"`
	PreSpawn    int `yaml:"preSpawn"`
}

AcceptorConfig amount of connections server can handle at same time

type AuthConfig

type AuthConfig struct {
	Anonymous bool     `yaml:"anonymous,omitempty" default:"false"`
	Order     []string `yaml:"order"`
}

type Config

type Config struct {
	System    SystemConfig    `yaml:"system"`
	Plugins   PluginsConfig   `yaml:"plugins,omitempty"`
	Mqtt      MqttConfig      `yaml:"mqtt,omitempty"`
	Listeners ListenersConfig `yaml:"listeners,omitempty"`
	Security  SecurityConfig  `yaml:"security,omitempty"`
	Auth      AuthConfig      `yaml:"auth,omitempty"`
}

Config system-wide config

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig Load minimum working configuration to allow server start without user provided one

func ReadConfig

func ReadConfig() *Config

ReadConfig read service configuration

type ConsoleLogConfig

type ConsoleLogConfig struct {
	LogConfigBase `yaml:",inline"`
}

ConsoleLogConfig entry in system.log.console

type FileLogConfig

type FileLogConfig struct {
	LogConfigBase `yaml:",inline"`
	File          string `yaml:"file,omitempty"`
	MaxSize       int    `yaml:"maxSize,omitempty"`
	MaxBackups    int    `yaml:"maxBackups,omitempty"`
	MaxAge        int    `yaml:"maxAge,omitempty"`
}

FileLogConfig entry in system.log.file

type ListenersConfig

type ListenersConfig struct {
	DefaultAddr string                           `yaml:"defaultAddr,omitempty"`
	MQTT        map[string]map[string]PortConfig `yaml:"mqtt,omitempty"`
}

ListenersConfig

type LogConfig

type LogConfig struct {
	Console ConsoleLogConfig `yaml:"console"`
	SysLog  *SysLogConfig    `yaml:"syslog,omitempty"`
	File    *FileLogConfig   `yaml:"file,omitempty"`
}

LogConfig entry in system.log

type LogConfigBase

type LogConfigBase struct {
	Timestamp *struct {
		Format string `yaml:"format" default:"2006-01-02T15:04:05Z07:00"`
	} `yaml:"timestamp,omitempty"`
	Level     string `yaml:"level"`
	Backtrace bool   `yaml:"backtrace"`
}

LogConfigBase base entry for all logger

func (*LogConfigBase) UnmarshalYAML

func (s *LogConfigBase) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshal log config

type MqttConfig

type MqttConfig struct {
	Version []string `yaml:"version,omitempty"`
	Systree struct {
		Enabled        bool `yaml:"enabled,omitempty"`
		UpdateInterval int  `yaml:"updateInterval,omitempty"`
	} `yaml:"systree,omitempty"`
	KeepAlive struct {
		Period int  `yaml:"period,omitempty"`
		Force  bool `yaml:"force,omitempty"`
	} `yaml:"keepAlive,omitempty"`
	Options struct {
		ConnectTimeout  int           `yaml:"connectTimeout,omitempty"`
		SessionDups     bool          `yaml:"sessionDups,omitempty"`
		RetainAvailable bool          `yaml:"retainAvailable,omitempty"`
		SubsOverlap     bool          `yaml:"subsOverlap,omitempty"`
		SubsID          bool          `yaml:"subsId,omitempty"`
		SubsShared      bool          `yaml:"subsShared,omitempty"`
		SubsWildcard    bool          `yaml:"subsWildcard,omitempty"`
		ReceiveMax      uint16        `yaml:"receiveMax,omitempty"`
		MaxPacketSize   uint32        `yaml:"maxPacketSize,omitempty"`
		MaxTopicAlias   uint16        `yaml:"maxTopicAlias,omitempty"`
		MaxQoS          mqttp.QosType `yaml:"maxQoS,omitempty"`
		OfflineQoS0     bool          `yaml:"offlineQoS0,omitempty"`
	}
}

MqttConfig server config

type Options

type Options struct {
	// LogWithTs either display timestamp messages on log or not
	LogWithTs bool
}

Options global MQTT config

type PluginState

type PluginState struct {
	Plugin vlplugin.Plugin
	Errors []error
}

PluginState status

type PluginsConfig

type PluginsConfig struct {
	Enabled []string               `yaml:"enabled,omitempty"`
	Config  map[string]interface{} `yaml:"config,omitempty"`
}

PluginsConfig entry in system.plugins

type PortConfig

type PortConfig struct {
	Host string     `yaml:"host,omitempty"`
	Auth AuthConfig `yaml:"auth"`
	TLS  TLSConfig  `yaml:"tls,omitempty"`
	Path string     `yaml:"path,omitempty"`
}

PortConfig configuration of tcp/ssl/ws(s) listeners

type SecurityConfig

type SecurityConfig struct {
	TLS TLSConfig `yaml:"tls,omitempty"`
}

SecurityConfig system security config

type SysLogConfig

type SysLogConfig struct {
	LogConfigBase `yaml:",inline"`
}

SysLogConfig entry in system.log.syslog

type SystemConfig

type SystemConfig struct {
	Log  LogConfig `yaml:"log"`
	Http struct {
		DefaultPort string `yaml:"defaultPort"`
	} `yaml:"http"`
	Acceptor AcceptorConfig `yaml:"acceptor"`
}

SystemConfig entry in system

type TLSConfig

type TLSConfig struct {
	Cert string `yaml:"cert,omitempty"`
	Key  string `yaml:"key,omitempty"`
}

TLSConfig used by SecurityConfig or ssl/ws listeners

func (*TLSConfig) LoadConfig

func (t *TLSConfig) LoadConfig() (*tls.Config, error)

func (*TLSConfig) Validate

func (t *TLSConfig) Validate() (tls.Certificate, error)

Jump to

Keyboard shortcuts

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