Documentation ¶
Overview ¶
Package metric provides an interface for describing a schema of metric's parameters.
Package metric provides an interface for describing a schema of metric's parameters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LenValidator ¶
func (LenValidator) Validate ¶
func (v LenValidator) Validate(value *string) error
type Metric ¶
type Metric struct {
// contains filtered or unexported fields
}
Metric stores a description of a metric and its parameters.
func New ¶
New creates an instance of a Metric and returns a pointer to it. It panics if a metric is not satisfied to one of the following rules: 1. Parameters must be named (and names must be unique). 2. It's forbidden to duplicate parameters' names. 3. Session must be placed first. 4. Connection parameters must be placed in a row.
func (*Metric) EvalParams ¶
func (m *Metric) EvalParams(rawParams []string, sessions interface{}) (params map[string]string, extraParams []string, err error)
EvalParams returns a mapping of parameters' names to their values passed to a plugin and/or sessions specified in the configuration file and extra remaining parameters. If a session is configured, then an other connection parameters must not be accepted and an error will be returned. Also it returns error in following cases: * incorrect number of parameters are passed; * missing required parameter; * value validation is failed.
type MetricSet ¶
MetricSet stores a mapping of keys to metrics.
type NumberValidator ¶
type NumberValidator struct{}
func (NumberValidator) Validate ¶
func (v NumberValidator) Validate(value *string) error
type Param ¶
type Param struct {
// contains filtered or unexported fields
}
Param stores parameters' metadata.
func NewConnParam ¶
NewConnParam creates a new connection parameter with given name and validator. Returns a pointer.
func NewParam ¶
NewParam creates a new parameter with given name and validator. Returns a pointer.
func NewSessionOnlyParam ¶
NewSessionParam creates a new connection parameter with given name and validator. Returns a pointer.
func (*Param) SetRequired ¶
SetRequired makes the parameter mandatory. It panics if default value is specified for required parameter.
func (*Param) WithDefault ¶
WithDefault sets the default value for a parameter. It panics if a default value is specified for a required parameter.
func (*Param) WithSession ¶
WithSession transforms a connection typed parameter to a dual purpose parameter which can be either a connection parameter or session name. Returns a pointer.
type PatternValidator ¶
type PatternValidator struct {
Pattern string
}
func (PatternValidator) Validate ¶
func (v PatternValidator) Validate(value *string) error
type RangeValidator ¶
func (RangeValidator) Validate ¶
func (v RangeValidator) Validate(value *string) error
type SetValidator ¶
func (SetValidator) Validate ¶
func (v SetValidator) Validate(value *string) error