config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultConfig is the default top-level configuration.
	DefaultConfig = Config{
		Global:  DefaultGlobalConfig,
		Metrics: DefaultMetricsConfig,
	}

	// DefaultGlobalConfig is the default global configuration.
	DefaultGlobalConfig = GlobalConfig{
		Retries: 3,
		Delta:   60,
	}

	// DefaultMetricsConfig is the default metrics configuration.
	DefaultMetricsConfig = MetricsConfig{
		Enable:  false,
		Address: "127.0.0.1:8337",
	}
)

Functions

This section is empty.

Types

type Check

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

Check representation

func NewCheck

func NewCheck(
	title string,
	processor p.Processor,
	notifier n.Notifier,
	retries uint,
) *Check

NewCheck returns a new check instance

func (*Check) GetNotifier

func (c *Check) GetNotifier() n.Notifier

GetNotifier returns the notifier from the current check

func (*Check) GetState

func (c *Check) GetState() p.State

GetState returns the current state from the latest processor

func (*Check) GetTitle

func (c *Check) GetTitle() string

GetTitle returns the title of the current check

func (*Check) IsRunning

func (c *Check) IsRunning() bool

IsRunning returns if the check is running right now

func (*Check) Run

func (c *Check) Run() error

Run the processor

type CheckConfig

type CheckConfig struct {
	Title     string          `yaml:"title"`
	Notifier  string          `yaml:"notifier"`
	Processor ProcessorConfig `yaml:"processor"`
}

CheckConfig struct for a check parameters

type ChecksConfig

type ChecksConfig struct {
	Checks []CheckConfig `yaml:"checks"`
}

ChecksConfig struct for a checks file

type Config

type Config struct {
	Global       GlobalConfig     `yaml:"global"`
	Metrics      MetricsConfig    `yaml:"metrics"`
	ChecksFolder string           `yaml:"checks_folder"`
	Notifiers    []NotifierConfig `yaml:"notifiers"`
}

Config struct for the main configuration file

func NewConfig

func NewConfig(path string) (*Config, error)

NewConfig loads the configuration from the YAML file

func (*Config) GetChecks

func (c *Config) GetChecks() ([]CheckConfig, error)

GetChecks returns the config for all checks inside the directory

func (*Config) Validate

func (c *Config) Validate() error

Validate verifis

type Container

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

Container contains checks and notifiers

func NewContainer

func NewContainer(logger *log.Logger) *Container

NewContainer creates a new container

func (*Container) GetChecks

func (ctn *Container) GetChecks() []c.Check

GetChecks returns all checks registered

func (*Container) GetDelta

func (ctn *Container) GetDelta() uint

GetDelta returns the number of seconds between two checks

func (*Container) GetMetrics added in v0.0.12

func (ctn *Container) GetMetrics() string

GetMetrics return the HTTP address for the Prometheus endpoint

func (*Container) GetNotifier

func (ctn *Container) GetNotifier(name string) (n.Notifier, error)

GetNotifier returns a notifier with a dedicated name

func (*Container) GetRetries

func (ctn *Container) GetRetries() uint

GetRetries returns the number of retries before sending notifications

func (*Container) Load

func (ctn *Container) Load(path string) error

Load loads all elements (notifiers, checks, ...) from the config into the container

type GlobalConfig

type GlobalConfig struct {
	Delta   uint `yaml:"delta,omitempty"`
	Retries uint `yaml:"retries,omitempty"`
}

GlobalConfig struct for global parameters

type Loader

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

Loader loads elements into the container from the config

func NewLoader

func NewLoader(logger *log.Logger) *Loader

NewLoader returns a new loader instance

func (*Loader) LoadChecks

func (l *Loader) LoadChecks(container *Container, configs []CheckConfig) error

LoadChecks loads checks from the config into the container

func (*Loader) LoadNotifiers

func (l *Loader) LoadNotifiers(container *Container, configs []NotifierConfig) error

LoadNotifiers loads notifiers from the config into the container

type MetricsConfig added in v0.0.12

type MetricsConfig struct {
	Enable  bool   `yaml:"enable,omitempty"`
	Address string `yaml:"address,omitempty"`
}

MetricsConfig struct for Prometheus metrics parameters

type NotifierConfig

type NotifierConfig struct {
	Name string            `yaml:"name"`
	Kind string            `yaml:"kind"`
	Data map[string]string `yaml:"data"`
}

NotifierConfig struct for a notifier parameters

type ProcessorConfig

type ProcessorConfig struct {
	Kind string            `yaml:"kind"`
	Data map[string]string `yaml:"data"`
}

ProcessorConfig struct for a processor parameters

Jump to

Keyboard shortcuts

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