config

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config implements various config structs required in the application.

It implements Check which implements the checker.Check and Component which implements the checker.Component interfaces.

Also implements the provider interface for metrics.

Subpackage configfile includes the configs that are implemented as config files for the application. This includes agents, central server and the app server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Service string `json:"service" mapstructure:"service"`
	Target  string `json:"target" mapstructure:"target"`
}

Alert configures where alert is to be sent.

func (*Alert) GetService

func (a *Alert) GetService() string

GetService returns the service name of the alert.

func (*Alert) GetTarget

func (a *Alert) GetTarget() string

GetTarget returns the target of the alert.

type AlertProvider

type AlertProvider struct {
	Service string `json:"service" mapstructure:"service"`
	Host    string `json:"host" mapstructure:"host"`
	Port    uint16 `json:"port" mapstructure:"port"`
	User    string `json:"user" mapstructure:"user"`
	Secret  string `json:"secret" mapstructure:"secret"`
}

AlertProvider configures the alerter.

This implements the alerter.Provider interface.

func (*AlertProvider) GetHost

func (a *AlertProvider) GetHost() string

GetHost returns the host name of the service provider.

func (*AlertProvider) GetPort

func (a *AlertProvider) GetPort() uint16

GetPort returns the port number of the service provider.

func (*AlertProvider) GetSecret

func (a *AlertProvider) GetSecret() string

GetSecret returns the secret key for configuring provider.

func (*AlertProvider) GetService

func (a *AlertProvider) GetService() string

GetService returns the service name of the provider.

func (*AlertProvider) GetUser

func (a *AlertProvider) GetUser() string

GetUser returns the user identifier of the service provider.

type Check

type Check struct {
	ID       string        `mapstructure:"id" json:"id"`
	Name     string        `mapstructure:"name" json:"name"`
	Interval time.Duration `mapstructure:"interval" json:"interval"`
	Timeout  time.Duration `mapstructure:"timeout" json:"timeout"`
	Input    Component     `mapstructure:"input" json:"input"`
	Output   Component     `mapstructure:"output" json:"output"`
	Target   Component     `mapstructure:"target" json:"target"`
	Payloads []Component   `mapstructure:"payloads" json:"payloads"`
	Alerts   []Alert       `mapstructure:"alerts" json:"alerts"`
}

Check is the configuration of each check associated with each check.

Implements checker.Check interface.

func ProtoToCheck

func ProtoToCheck(check *proto.Check) Check

ProtoToCheck converts a proto.Check into checker.Check.

func (*Check) GetID

func (c *Check) GetID() string

GetID returns the ID for the check.

func (*Check) GetInput

func (c *Check) GetInput() checker.Component

GetInput returns the input of the check.

func (*Check) GetInterval

func (c *Check) GetInterval() time.Duration

GetInterval returns the interval of the check.

func (*Check) GetName

func (c *Check) GetName() string

GetName returns the name of the check.

func (*Check) GetOutput

func (c *Check) GetOutput() checker.Component

GetOutput returns the output of the check.

func (*Check) GetPayloads

func (c *Check) GetPayloads() []checker.Component

GetPayloads returns the payloads for the check.

func (*Check) GetTarget

func (c *Check) GetTarget() checker.Component

GetTarget returns the target of the check.

func (*Check) GetTimeout

func (c *Check) GetTimeout() time.Duration

GetTimeout returns the timeout of the check.

type Component

type Component struct {
	Type  string `mapstructure:"type" json:"type"`
	Value string `mapstructure:"value" json:"value"`
}

Component is a key-value pair.

Implements Component interface.

func (*Component) GetType

func (c *Component) GetType() string

GetType returns the type of the component.

func (*Component) GetValue

func (c *Component) GetValue() string

GetValue returns the value of the component.

type DBConn

type DBConn struct {
	Host     string
	Port     uint16
	Name     string
	Username string
	Password string
	SSLMode  bool
}

DBConn config

func (*DBConn) GetHost

func (m *DBConn) GetHost() string

GetHost returns the host of the database provider.

func (*DBConn) GetName

func (m *DBConn) GetName() string

GetName returns the name of the provider.

func (*DBConn) GetPassword

func (m *DBConn) GetPassword() string

GetPassword returns the password of the database provider.

func (*DBConn) GetPort

func (m *DBConn) GetPort() uint16

GetPort returns the port of the database provider.

func (*DBConn) GetUsername

func (m *DBConn) GetUsername() string

GetUsername returns the username of the database provider.

func (*DBConn) IsSSLMode

func (m *DBConn) IsSSLMode() bool

IsSSLMode tells if the connection with the provider is to be established through SSL.

type Metric

type Metric struct {
	CheckID    string
	CheckName  string
	Successful bool
	Timeout    bool
	StartTime  time.Time
	Duration   time.Duration
}

Metric represents the result of a check.

Implements the checker.Metric interface.

func (*Metric) GetCheckID

func (m *Metric) GetCheckID() string

GetCheckID returns the ID of the check for which the metric is.

func (*Metric) GetCheckName

func (m *Metric) GetCheckName() string

GetCheckName returns the name of the check.

func (*Metric) GetDuration

func (m *Metric) GetDuration() time.Duration

GetDuration returns the duration that check took to run.

func (*Metric) GetStartTime

func (m *Metric) GetStartTime() time.Time

GetStartTime returns the start-time of the check.

func (*Metric) IsSuccessful

func (m *Metric) IsSuccessful() bool

IsSuccessful tells if the check was successful.

func (*Metric) IsTimeout

func (m *Metric) IsTimeout() bool

IsTimeout tells if the check timed-out.

type MetricsProvider

type MetricsProvider struct {
	Backend  string `mapstructure:"backend" json:"backend"`
	Host     string `mapstructure:"host" json:"host"`
	Port     uint16 `mapstructure:"port" json:"port"`
	DBName   string `mapstructure:"db_name" json:"db_name"`
	Username string `mapstructure:"username" json:"username"`
	Password string `mapstructure:"password" json:"password"`
	SSLMode  bool   `mapstructure:"ssl_mode" json:"ssl_mode"`
}

MetricsProvider represents the configuration of a metrics exporter.

Implements the metrics.Provider interface.

func (*MetricsProvider) GetBackend

func (m *MetricsProvider) GetBackend() string

GetBackend returns the backend of the provider.

func (*MetricsProvider) GetDBName

func (m *MetricsProvider) GetDBName() string

GetDBName returns the database name of the provider.

func (*MetricsProvider) GetHost

func (m *MetricsProvider) GetHost() string

GetHost returns the host of the database provider.

func (*MetricsProvider) GetPassword

func (m *MetricsProvider) GetPassword() string

GetPassword returns the password of the database provider.

func (*MetricsProvider) GetPort

func (m *MetricsProvider) GetPort() uint16

GetPort returns the port of the database provider.

func (*MetricsProvider) GetUsername

func (m *MetricsProvider) GetUsername() string

GetUsername returns the username of the database provider.

func (*MetricsProvider) IsSSLMode

func (m *MetricsProvider) IsSSLMode() bool

IsSSLMode tells if the connection with the provider is to be established through SSL.

type OauthProvider

type OauthProvider struct {
	Provider     string   `mapstructure:"provider" json:"provider"`
	ClientID     string   `mapstructure:"client_id" json:"client_id"`
	ClientSecret string   `mapstructure:"client_secret" json:"client_secret"`
	RedirectURL  string   `mapstructure:"redirect_url" json:"redirect_url"`
	Scopes       []string `mapstructure:"scopes" json:"scopes"`
}

OauthProvider is configures the service that provides authentication through OAuth2.

func (*OauthProvider) GetClientID

func (o *OauthProvider) GetClientID() string

GetClientID returns the client ID of the provider.

func (*OauthProvider) GetClientSecret

func (o *OauthProvider) GetClientSecret() string

GetClientSecret returns the client secret of the provider.

func (*OauthProvider) GetProvider

func (o *OauthProvider) GetProvider() string

GetProvider returns the provider name.

func (*OauthProvider) GetRedirectURL

func (o *OauthProvider) GetRedirectURL() string

GetRedirectURL returns the redirect URL.

func (*OauthProvider) GetScopes

func (o *OauthProvider) GetScopes() []string

GetScopes returns the scopes.

Directories

Path Synopsis
Package configfile contains the config structures for the components which are to be represented by a config file.
Package configfile contains the config structures for the components which are to be represented by a config file.

Jump to

Keyboard shortcuts

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