providers

package
v0.0.0-...-f3e8d88 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

README

package providers

Providers implement the ConfigProvider interface and are responsible for scanning different sources like files on disk, environment variables or databases, searching for check configurations. Every configuration, regardless of the format, must specify at least one check instance. Providers dump every configuration they find into a CheckConfig struct containing an array of configuration instances. Configuration instances are converted in YAML format so that a check object will be eventually able to convert them into the appropriate data structure.

Usage example:

var configs []loader.CheckConfig
for _, provider := range configProviders {
  c, _ := provider.Collect()
  configs = append(configs, c...)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderCatalog = make(map[string]ConfigProviderFactory)

ProviderCatalog keeps track of config providers by name

Functions

func GetCheckConfigFromFile

func GetCheckConfigFromFile(name, fpath string) (check.Config, error)

GetCheckConfigFromFile returns an instance of check.Config if `fpath` points to a valid config file

func RegisterProvider

func RegisterProvider(name string, factory ConfigProviderFactory)

RegisterProvider adds a loader to the providers catalog

Types

type ADEntryIndex

type ADEntryIndex struct {
	NamesIdx     uint64
	InitIdx      uint64
	InstancesIdx uint64
}

ADEntryIndex structure to store indeces to backend entries

type ConfigProvider

type ConfigProvider interface {
	Collect() ([]check.Config, error)
}

ConfigProvider is the interface that wraps the Collect method

Collect is responsible of populating a list of CheckConfig instances by retrieving configuration patterns from external resources: files on disk, databases, environment variables are just few examples.

Any type implementing the interface will take care of any dependency or data needed to access the resource providing the configuration.

type ConfigProviderFactory

type ConfigProviderFactory func(cfg config.ConfigurationProviders) (ConfigProvider, error)

ConfigProviderFactory is any function capable to create a ConfigProvider instance

type FileConfigProvider

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

FileConfigProvider collect configuration files from disk

func NewFileConfigProvider

func NewFileConfigProvider(paths []string) *FileConfigProvider

NewFileConfigProvider creates a new FileConfigProvider searching for configuration files on the given paths

func (*FileConfigProvider) Collect

func (c *FileConfigProvider) Collect() ([]check.Config, error)

Collect scans provided paths searching for configuration files. When found, it parses the files and try to unmarshall Yaml contents into a CheckConfig instance

func (*FileConfigProvider) String

func (c *FileConfigProvider) String() string

Jump to

Keyboard shortcuts

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