Loading & namespacing external plugins

This commit is contained in:
Cameron Sparr
2017-02-06 16:45:35 +00:00
parent 2eee1b84fb
commit f4e48f9909
9 changed files with 78 additions and 5 deletions

View File

@@ -1,11 +1,20 @@
package processors
import "github.com/influxdata/telegraf"
import (
"log"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/registry"
)
type Creator func() telegraf.Processor
var Processors = map[string]Creator{}
func Add(name string, creator Creator) {
if override := registry.GetName(); override != "" {
name = override
}
log.Println("D! Loading plugin: [[processors." + name + "]]")
Processors[name] = creator
}