forked from ligato/vpp-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
38 lines (29 loc) · 853 Bytes
/
options.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 telemetry
import (
"github.com/ligato/cn-infra/rpc/prometheus"
"github.com/ligato/cn-infra/servicelabel"
"github.com/ligato/vpp-agent/plugins/govppmux"
)
// DefaultPlugin is default instance of Plugin
var DefaultPlugin = *NewPlugin()
// NewPlugin creates a new Plugin with the provides Options
func NewPlugin(opts ...Option) *Plugin {
p := &Plugin{}
p.PluginName = "telemetry"
p.ServiceLabel = &servicelabel.DefaultPlugin
p.GoVppmux = &govppmux.DefaultPlugin
p.Prometheus = &prometheus.DefaultPlugin
for _, o := range opts {
o(p)
}
p.PluginDeps.Setup()
return p
}
// Option is a function that acts on a Plugin to inject Dependencies or configuration
type Option func(*Plugin)
// UseDeps returns Option that can inject custom dependencies.
func UseDeps(cb func(*Deps)) Option {
return func(p *Plugin) {
cb(&p.Deps)
}
}