diff options
author | Valery Piashchynski <[email protected]> | 2021-06-02 21:23:42 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-02 21:23:42 +0300 |
commit | 9c01e7ab1548e1416598b702d63866fa6dc5707b (patch) | |
tree | 35056e2a44cc8427b857399a9eb154c15986d22e /plugins/informer/plugin.go | |
parent | a99c14abb333c10a9142cd2f178e001f1b1726fb (diff) | |
parent | 42c0d32eb2e28fee3d084d887552b1ebafdd66c6 (diff) |
#699 fix(bug): return `nil` if there are no workers in the requested pluginv2.3.0-beta.1
#699 fix(bug): return `nil` if there are no workers in the requested plugin
Diffstat (limited to 'plugins/informer/plugin.go')
-rw-r--r-- | plugins/informer/plugin.go | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/plugins/informer/plugin.go b/plugins/informer/plugin.go index 2d76123b..f8725ed7 100644 --- a/plugins/informer/plugin.go +++ b/plugins/informer/plugin.go @@ -2,32 +2,30 @@ package informer import ( endure "github.com/spiral/endure/pkg/container" - "github.com/spiral/errors" "github.com/spiral/roadrunner/v2/pkg/process" ) const PluginName = "informer" type Plugin struct { - registry map[string]Informer - available map[string]Availabler + withWorkers map[string]Informer + available map[string]Availabler } func (p *Plugin) Init() error { p.available = make(map[string]Availabler) - p.registry = make(map[string]Informer) + p.withWorkers = make(map[string]Informer) return nil } // Workers provides BaseProcess slice with workers for the requested plugin -func (p *Plugin) Workers(name string) ([]process.State, error) { - const op = errors.Op("informer_plugin_workers") - svc, ok := p.registry[name] +func (p *Plugin) Workers(name string) []process.State { + svc, ok := p.withWorkers[name] if !ok { - return nil, errors.E(op, errors.Errorf("no such service: %s", name)) + return nil } - return svc.Workers(), nil + return svc.Workers() } // Collects declares services to be collected. @@ -45,7 +43,7 @@ func (p *Plugin) CollectPlugins(name endure.Named, l Availabler) { // CollectWorkers obtains plugins with workers inside. func (p *Plugin) CollectWorkers(name endure.Named, r Informer) { - p.registry[name.Name()] = r + p.withWorkers[name.Name()] = r } // Name of the service. |