diff --git a/go.mod b/go.mod index 12ef7b96a..7991d130c 100644 --- a/go.mod +++ b/go.mod @@ -35,3 +35,7 @@ require ( golang.org/x/sync v0.0.0-20201207232520-09787c993a3a golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 ) + +replace ( + github.com/spiral/endure v1.0.1 => ../endure +) diff --git a/plugins/informer/interface.go b/plugins/informer/interface.go index 45f44691e..cd8ab232f 100644 --- a/plugins/informer/interface.go +++ b/plugins/informer/interface.go @@ -8,3 +8,9 @@ import ( type Informer interface { Workers() []process.State } + +// Lister interface used to filter available plugins +type Lister interface { + // List gets no args, but returns list of the active plugins + List() []string +} diff --git a/plugins/informer/plugin.go b/plugins/informer/plugin.go index 98081d345..3d219cda0 100644 --- a/plugins/informer/plugin.go +++ b/plugins/informer/plugin.go @@ -11,6 +11,7 @@ const PluginName = "informer" type Plugin struct { registry map[string]Informer + plugins map[string]Lister log logger.Logger } @@ -31,19 +32,24 @@ func (p *Plugin) Workers(name string) ([]process.State, error) { return svc.Workers(), nil } -// CollectTarget resettable service. -func (p *Plugin) CollectTarget(name endure.Named, r Informer) error { - p.registry[name.Name()] = r - return nil -} - // Collects declares services to be collected. func (p *Plugin) Collects() []interface{} { return []interface{}{ - p.CollectTarget, + p.CollectWorkers, } } +// CollectPlugins collects all RR plugins +func (p *Plugin) CollectPlugins(name endure.Named, l Lister) { + p.plugins[name.Name()] = l +} + +// CollectWorkers obtains plugins with workers inside. +func (p *Plugin) CollectWorkers(name endure.Named, r Informer) error { + p.registry[name.Name()] = r + return nil +} + // Name of the service. func (p *Plugin) Name() string { return PluginName