config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeviceValidation

func DeviceValidation(device Device) error

DeviceValidation validates configured device.

func GetDefaultLogger

func GetDefaultLogger() *zap.Logger

GetDefaultLogger creates default zap logger.

func GetEnvInt

func GetEnvInt(name string, defaultValue int) int

GetEnvInt returns given env variable in integer if available otherwise it returns the default value.

func GetLogger

func GetLogger(lcfg map[string]interface{}) *zap.Logger

GetLogger tries to create a zap logger based on the user configuration.

func GetVersion

func GetVersion() string

GetVersion returns Panoptes version

func SensorValidation

func SensorValidation(sensor Sensor) error

SensorValidation validates configured sensor.

func SetDefault

func SetDefault(s interface{}, d interface{})

SetDefault set default value if the s == zero.

func SetDefaultGlobal

func SetDefaultGlobal(g *Global)

SetDefaultGlobal set global default value.

Types

type Config

type Config interface {
	Devices() []Device
	Producers() []Producer
	Databases() []Database
	Sensors() []Sensor
	Global() *Global
	Informer() chan struct{}
	Logger() *zap.Logger
	Update() error
}

Config represets panoptes configuration

type Database

type Database struct {
	Name    string
	Service string
	Config  interface{}
}

Database represents database configuration

type Device

type Device struct {
	DeviceConfig

	Sensors map[string][]*Sensor
}

Device represents device configuration with sensors

func ConvDeviceTemplate

func ConvDeviceTemplate(d DeviceTemplate) Device

ConvDeviceTemplate transforms devicetemplate to device.

type DeviceConfig

type DeviceConfig struct {
	Host string
	Port int

	GroupID int

	DeviceOptions `yaml:",inline"`
}

DeviceConfig represents device configuration

type DeviceOptions

type DeviceOptions struct {
	TLSConfig TLSConfig `yaml:"tlsConfig"`
	Username  string
	Password  string
}

DeviceOptions represents global device options

type DeviceTemplate

type DeviceTemplate struct {
	DeviceConfig `yaml:",inline"`

	Sensors []string
}

DeviceTemplate represents device configuration structure

type Dialout

type Dialout struct {
	TLSConfig     TLSConfig `yaml:"tlsConfig"`
	DefaultOutput string    `yaml:"defaultOutput"`
	Services      map[string]DialoutService
}

Dialout represents dialout service

type DialoutService

type DialoutService struct {
	Addr    string
	Workers int
}

DialoutService represent specific dialout telemetry

type Discovery

type Discovery struct {
	Service string
	Config  interface{}
}

Discovery represents discovery service

type Global

type Global struct {
	Discovery        Discovery
	Status           Status
	Shards           Shards
	DeviceOptions    DeviceOptions `yaml:"deviceOptions"`
	WatcherDisabled  bool          `yaml:"watcherDisabled"`
	BufferSize       int           `yaml:"bufferSize"`
	OutputBufferSize int           `yaml:"outputBufferSize"`
	Version          string
	Logger           map[string]interface{}
	Dialout          Dialout
}

Global represents global configuration

type MemSink

type MemSink struct {
	*bytes.Buffer
}

MemSink represents memory destination for logging.

func (*MemSink) Close

func (s *MemSink) Close() error

Close is required method for sink interface.

func (*MemSink) Sync

func (s *MemSink) Sync() error

Sync is required method for sink interface.

func (*MemSink) Unmarshal

func (s *MemSink) Unmarshal() map[string]string

Unmarshal returns decoded data as key value and reset the buffer.

func (*MemSink) UnmarshalSlice

func (s *MemSink) UnmarshalSlice() []map[string]string

UnmarshalSlice returns array of decoded logs as key value and reset the buffer.

type MockConfig

type MockConfig struct {
	MDevices   []Device
	MProducers []Producer
	MDatabases []Database
	MSensors   []Sensor
	MGlobal    *Global

	MInformer chan struct{}

	LogOutput *MemSink
	// contains filtered or unexported fields
}

MockConfig represents mock configuration.

func NewMockConfig

func NewMockConfig() *MockConfig

NewMockConfig constructs mock configuration it writes logs to memory and accessible from LogOutput.

func (*MockConfig) Databases

func (m *MockConfig) Databases() []Database

Databases returns configured databases.

func (*MockConfig) Devices

func (m *MockConfig) Devices() []Device

Devices returns configured devices.

func (*MockConfig) Global

func (m *MockConfig) Global() *Global

Global returns global configuration.

func (*MockConfig) Informer

func (m *MockConfig) Informer() chan struct{}

Informer returns informer channel.

func (*MockConfig) Logger

func (m *MockConfig) Logger() *zap.Logger

Logger returns zap logger pointer.

func (*MockConfig) Producers

func (m *MockConfig) Producers() []Producer

Producers returns configured producers.

func (*MockConfig) Sensors

func (m *MockConfig) Sensors() []Sensor

Sensors returns configured sensors.

func (*MockConfig) Update

func (m *MockConfig) Update() error

Update is mock update.

type Producer

type Producer struct {
	Name    string
	Service string
	Config  interface{}
}

Producer represents producer configuration

type Sensor

type Sensor struct {
	Service  string
	Output   string
	Disabled bool

	Origin            string
	Path              string
	Mode              string
	SampleInterval    int  `yaml:"sampleInterval"`
	HeartbeatInterval int  `yaml:"heartbeatInterval"`
	SuppressRedundant bool `yaml:"suppressRedundant"`

	Subscription string
}

Sensor represents telemetry sensor

type Shards

type Shards struct {
	Enabled            bool
	InitializingShards int `yaml:"initializingShards"`
	NumberOfNodes      int `yaml:"numberOfNodes"`
}

Shards represents shard service configuration

type Status

type Status struct {
	Addr      string
	Disabled  bool
	TLSConfig TLSConfig `yaml:"tlsConfig"`
}

Status represents status: self monitoring and healthcheck configuration

type TLSConfig

type TLSConfig struct {
	Enabled bool

	CertFile           string `yaml:"certFile"`
	KeyFile            string `yaml:"keyFile"`
	CAFile             string `yaml:"caFile"`
	InsecureSkipVerify bool   `yaml:"insecureSkipVerify"`
}

TLSConfig represents TLS client configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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