-
Notifications
You must be signed in to change notification settings - Fork 0
/
pregistry.go
38 lines (30 loc) · 886 Bytes
/
pregistry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package plugins
import (
"github.com/thingsplex/tpflow/connector/model"
"github.com/thingsplex/tpflow/connector/plugins/fimpmqtt"
"github.com/thingsplex/tpflow/connector/plugins/influxdb"
)
var pluginRegistry = map[string]model.Plugin{
"influxdb": {Constructor: influxdb.NewConnectorInstance, Config: influxdb.ConnectorConfig{}},
"fimpmqtt": {Constructor: fimpmqtt.NewConnectorInstance, Config: fimpmqtt.ConnectorConfig{}},
}
func GetPlugin(name string) *model.Plugin {
plugin, ok := pluginRegistry[name]
if ok {
return &plugin
}
return nil
}
func RegisterPlugin(name string, plugin model.Plugin) {
pluginRegistry[name] = plugin
}
func GetConfigurationTemplate(name string) model.Instance {
inst := model.Instance{}
if p := GetPlugin(name); p != nil {
inst.Config = p.Config
}
return inst
}
func GetPlugins() map[string]model.Plugin {
return pluginRegistry
}