diff options
author | Valery Piashchynski <[email protected]> | 2021-09-16 21:46:50 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-09-16 21:46:50 +0300 |
commit | 3581b45f237a3f7aa29591ceb2bf6f4a4642a2f5 (patch) | |
tree | e723b19ec1ac16b7ccc7b3c2da69d4a416d63d81 /plugins/informer/plugin.go | |
parent | 337d292dd2d6ff0a555098b1970d8194d8df8bc2 (diff) | |
parent | 823d831b57b75f70c7c3bbbee355f2016633bb3b (diff) |
[#803]: feat(plugins): move plugins to a separate repositoryv2.5.0-alpha.2
[#803]: feat(plugins): move plugins to a separate repository
Diffstat (limited to 'plugins/informer/plugin.go')
-rw-r--r-- | plugins/informer/plugin.go | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/plugins/informer/plugin.go b/plugins/informer/plugin.go deleted file mode 100644 index 87180be5..00000000 --- a/plugins/informer/plugin.go +++ /dev/null @@ -1,89 +0,0 @@ -package informer - -import ( - "context" - - endure "github.com/spiral/endure/pkg/container" - "github.com/spiral/roadrunner/v2/pkg/state/job" - "github.com/spiral/roadrunner/v2/pkg/state/process" - "github.com/spiral/roadrunner/v2/plugins/logger" -) - -const PluginName = "informer" - -type Plugin struct { - log logger.Logger - - withJobs map[string]JobsStat - withWorkers map[string]Informer - available map[string]Availabler -} - -func (p *Plugin) Init(log logger.Logger) error { - p.available = make(map[string]Availabler) - p.withWorkers = make(map[string]Informer) - p.withJobs = make(map[string]JobsStat) - - p.log = log - return nil -} - -// Workers provides BaseProcess slice with workers for the requested plugin -func (p *Plugin) Workers(name string) []*process.State { - svc, ok := p.withWorkers[name] - if !ok { - return nil - } - - return svc.Workers() -} - -// Jobs provides information about jobs for the registered plugin using jobs -func (p *Plugin) Jobs(name string) []*job.State { - svc, ok := p.withJobs[name] - if !ok { - return nil - } - - st, err := svc.JobsState(context.Background()) - if err != nil { - p.log.Info("jobs stat", "error", err) - // skip errors here - return nil - } - - return st -} - -// Collects declares services to be collected. -func (p *Plugin) Collects() []interface{} { - return []interface{}{ - p.CollectPlugins, - p.CollectWorkers, - p.CollectJobs, - } -} - -// CollectPlugins collects all RR plugins -func (p *Plugin) CollectPlugins(name endure.Named, l Availabler) { - p.available[name.Name()] = l -} - -// CollectWorkers obtains plugins with workers inside. -func (p *Plugin) CollectWorkers(name endure.Named, r Informer) { - p.withWorkers[name.Name()] = r -} - -func (p *Plugin) CollectJobs(name endure.Named, j JobsStat) { - p.withJobs[name.Name()] = j -} - -// Name of the service. -func (p *Plugin) Name() string { - return PluginName -} - -// RPC returns associated rpc service. -func (p *Plugin) RPC() interface{} { - return &rpc{srv: p} -} |