summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-04-29 19:26:35 +0300
committerValery Piashchynski <[email protected]>2021-04-29 19:26:35 +0300
commitaf707e7d4d7a8fad98872e2a902e056155ad9591 (patch)
tree8f5ad1f1be443281213c4fccc1e77ca43a749f05 /plugins
parent7297e5f2fad841466024f8622da3e14b7874f989 (diff)
- Add new interface to obtain all plugins
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/informer/interface.go6
-rw-r--r--plugins/informer/plugin.go20
2 files changed, 19 insertions, 7 deletions
diff --git a/plugins/informer/interface.go b/plugins/informer/interface.go
index 45f44691..cd8ab232 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 98081d34..3d219cda 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