telegraf/plugins/inputs/registry.go

57 lines
1.4 KiB
Go
Raw Normal View History

2016-01-07 20:39:43 +00:00
package inputs
import "time"
type Accumulator interface {
// Create a point with a value, decorating it with tags
// NOTE: tags is expected to be owned by the caller, don't mutate
// it after passing to Add.
Add(measurement string,
value interface{},
tags map[string]string,
t ...time.Time)
AddFields(measurement string,
fields map[string]interface{},
tags map[string]string,
t ...time.Time)
}
2016-01-07 20:39:43 +00:00
type Input interface {
// SampleConfig returns the default configuration of the Input
SampleConfig() string
2016-01-07 20:39:43 +00:00
// Description returns a one-sentence description on the Input
Description() string
2016-01-07 20:39:43 +00:00
// Gather takes in an accumulator and adds the metrics that the Input
// gathers. This is called every "interval"
Gather(Accumulator) error
}
2016-01-07 20:39:43 +00:00
type ServiceInput interface {
// SampleConfig returns the default configuration of the Input
SampleConfig() string
2016-01-07 20:39:43 +00:00
// Description returns a one-sentence description on the Input
Description() string
2016-01-07 20:39:43 +00:00
// Gather takes in an accumulator and adds the metrics that the Input
// gathers. This is called every "interval"
Gather(Accumulator) error
2016-01-07 20:39:43 +00:00
// Start starts the ServiceInput's service, whatever that may be
Start() error
// Stop stops the services and closes any necessary channels and connections
Stop()
}
2016-01-07 20:39:43 +00:00
type Creator func() Input
2016-01-07 20:39:43 +00:00
var Inputs = map[string]Creator{}
func Add(name string, creator Creator) {
2016-01-07 20:39:43 +00:00
Inputs[name] = creator
}