-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading & namespacing external plugins
- Loading branch information
Showing
9 changed files
with
73 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
package aggregators | ||
|
||
import "github.com/influxdata/telegraf" | ||
import ( | ||
"log" | ||
|
||
"github.com/influxdata/telegraf" | ||
"github.com/influxdata/telegraf/registry" | ||
) | ||
|
||
type Creator func() telegraf.Aggregator | ||
|
||
var Aggregators = map[string]Creator{} | ||
|
||
func Add(name string, creator Creator) { | ||
if override := registry.GetName(); override != "" { | ||
name = override | ||
} | ||
log.Println("D! Loading plugin: [[aggregators." + name + "]]") | ||
Aggregators[name] = creator | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
package inputs | ||
|
||
import "github.com/influxdata/telegraf" | ||
import ( | ||
"log" | ||
|
||
"github.com/influxdata/telegraf" | ||
"github.com/influxdata/telegraf/registry" | ||
) | ||
|
||
type Creator func() telegraf.Input | ||
|
||
var Inputs = map[string]Creator{} | ||
|
||
func Add(name string, creator Creator) { | ||
if override := registry.GetName(); override != "" { | ||
name = override | ||
} | ||
log.Println("D! Loading plugin: [[inputs." + name + "]]") | ||
Inputs[name] = creator | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package registry | ||
|
||
import ( | ||
"sync" | ||
) | ||
|
||
var nameOverride string | ||
var mu sync.Mutex | ||
|
||
func SetName(s string) { | ||
mu.Lock() | ||
nameOverride = s | ||
mu.Unlock() | ||
} | ||
|
||
func GetName() string { | ||
mu.Lock() | ||
defer mu.Unlock() | ||
return nameOverride | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
package outputs | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/influxdata/telegraf" | ||
"github.com/influxdata/telegraf/registry" | ||
) | ||
|
||
type Creator func() telegraf.Output | ||
|
||
var Outputs = map[string]Creator{} | ||
|
||
func Add(name string, creator Creator) { | ||
if override := registry.GetName(); override != "" { | ||
name = override | ||
} | ||
log.Println("D! Loading plugin: [[outputs." + name + "]]") | ||
Outputs[name] = creator | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |