2016-09-08 14:22:10 +00:00
|
|
|
package processors
|
|
|
|
|
|
|
|
import "github.com/influxdata/telegraf"
|
|
|
|
|
|
|
|
type Creator func() telegraf.Processor
|
2020-06-05 14:43:43 +00:00
|
|
|
type StreamingCreator func() telegraf.StreamingProcessor
|
2016-09-08 14:22:10 +00:00
|
|
|
|
2020-06-05 14:43:43 +00:00
|
|
|
// all processors are streaming processors.
|
|
|
|
// telegraf.Processor processors are upgraded to telegraf.StreamingProcessor
|
|
|
|
var Processors = map[string]StreamingCreator{}
|
2016-09-08 14:22:10 +00:00
|
|
|
|
2020-06-05 14:43:43 +00:00
|
|
|
// Add adds a telegraf.Processor processor
|
2016-09-08 14:22:10 +00:00
|
|
|
func Add(name string, creator Creator) {
|
2020-06-05 14:43:43 +00:00
|
|
|
Processors[name] = upgradeToStreamingProcessor(creator)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddStreaming adds a telegraf.StreamingProcessor streaming processor
|
|
|
|
func AddStreaming(name string, creator StreamingCreator) {
|
2016-09-08 14:22:10 +00:00
|
|
|
Processors[name] = creator
|
|
|
|
}
|
2020-06-05 14:43:43 +00:00
|
|
|
|
|
|
|
func upgradeToStreamingProcessor(oldCreator Creator) StreamingCreator {
|
|
|
|
return func() telegraf.StreamingProcessor {
|
|
|
|
return NewStreamingProcessorFromProcessor(oldCreator())
|
|
|
|
}
|
|
|
|
}
|