diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/informer/plugin.go | 18 | ||||
-rw-r--r-- | plugins/informer/rpc.go | 9 |
2 files changed, 13 insertions, 14 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. diff --git a/plugins/informer/rpc.go b/plugins/informer/rpc.go index 8955af92..3925ef64 100644 --- a/plugins/informer/rpc.go +++ b/plugins/informer/rpc.go @@ -16,7 +16,7 @@ type WorkerList struct { // List all resettable services. func (rpc *rpc) List(_ bool, list *[]string) error { - *list = make([]string, 0, len(rpc.srv.registry)) + *list = make([]string, 0, len(rpc.srv.withWorkers)) // append all plugin names to the output result for name := range rpc.srv.available { @@ -27,9 +27,10 @@ func (rpc *rpc) List(_ bool, list *[]string) error { // Workers state of a given service. func (rpc *rpc) Workers(service string, list *WorkerList) error { - workers, err := rpc.srv.Workers(service) - if err != nil { - return err + workers := rpc.srv.Workers(service) + if workers == nil { + list = nil + return nil } // write actual processes |