summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-04-30 13:09:18 +0300
committerValery Piashchynski <[email protected]>2021-04-30 13:09:18 +0300
commitd0dccb0c761df45da7fba00340f1cd5c66c71711 (patch)
tree8b1bc547a843dd9601faee26cf1c92876cfbb054 /plugins
parent50aa751dcefc0ab0e96594a5f111ead316a34a70 (diff)
- Add Availabler interface implementaion for all plugins
- Add tests Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/config/plugin.go15
-rw-r--r--plugins/informer/plugin.go2
-rw-r--r--plugins/logger/plugin.go10
-rw-r--r--plugins/metrics/plugin.go5
-rw-r--r--plugins/redis/plugin.go5
-rw-r--r--plugins/reload/plugin.go5
-rw-r--r--plugins/resetter/plugin.go5
-rw-r--r--plugins/rpc/plugin.go5
-rw-r--r--plugins/server/plugin.go5
-rw-r--r--plugins/service/plugin.go5
-rw-r--r--plugins/status/plugin.go7
11 files changed, 67 insertions, 2 deletions
diff --git a/plugins/config/plugin.go b/plugins/config/plugin.go
index eb7146b2..a5215226 100755
--- a/plugins/config/plugin.go
+++ b/plugins/config/plugin.go
@@ -10,6 +10,8 @@ import (
"github.com/spiral/errors"
)
+const PluginName string = "config"
+
type Viper struct {
viper *viper.Viper
Path string
@@ -118,6 +120,19 @@ func (v *Viper) GetCommonConfig() *General {
return v.CommonConfig
}
+func (v *Viper) Serve() chan error {
+ return make(chan error, 1)
+}
+
+func (v *Viper) Stop() error {
+ return nil
+}
+
+// Name returns user-friendly plugin name
+func (v *Viper) Name() string {
+ return PluginName
+}
+
// Available interface implementation
func (v *Viper) Available() bool {
return true
diff --git a/plugins/informer/plugin.go b/plugins/informer/plugin.go
index 73e49575..2d76123b 100644
--- a/plugins/informer/plugin.go
+++ b/plugins/informer/plugin.go
@@ -33,8 +33,8 @@ func (p *Plugin) Workers(name string) ([]process.State, error) {
// Collects declares services to be collected.
func (p *Plugin) Collects() []interface{} {
return []interface{}{
- p.CollectWorkers,
p.CollectPlugins,
+ p.CollectWorkers,
}
}
diff --git a/plugins/logger/plugin.go b/plugins/logger/plugin.go
index e1066cba..86275a85 100644
--- a/plugins/logger/plugin.go
+++ b/plugins/logger/plugin.go
@@ -81,3 +81,13 @@ func (z *ZapLogger) Provides() []interface{} {
z.DefaultLogger,
}
}
+
+// Name returns user-friendly plugin name
+func (z *ZapLogger) Name() string {
+ return PluginName
+}
+
+// Available interface implementation
+func (z *ZapLogger) Available() bool {
+ return true
+}
diff --git a/plugins/metrics/plugin.go b/plugins/metrics/plugin.go
index d0443177..df6ea122 100644
--- a/plugins/metrics/plugin.go
+++ b/plugins/metrics/plugin.go
@@ -222,3 +222,8 @@ func (m *Plugin) RPC() interface{} {
log: m.log,
}
}
+
+// Available interface implementation
+func (m *Plugin) Available() bool {
+ return true
+}
diff --git a/plugins/redis/plugin.go b/plugins/redis/plugin.go
index 204abd17..b69af9d6 100644
--- a/plugins/redis/plugin.go
+++ b/plugins/redis/plugin.go
@@ -76,3 +76,8 @@ func (s Plugin) Stop() error {
func (s *Plugin) Name() string {
return PluginName
}
+
+// Available interface implementation
+func (s *Plugin) Available() bool {
+ return true
+}
diff --git a/plugins/reload/plugin.go b/plugins/reload/plugin.go
index bf88462e..d2c22fe8 100644
--- a/plugins/reload/plugin.go
+++ b/plugins/reload/plugin.go
@@ -161,3 +161,8 @@ func (s *Plugin) Stop() error {
func (s *Plugin) Name() string {
return PluginName
}
+
+// Available interface implementation
+func (s *Plugin) Available() bool {
+ return true
+}
diff --git a/plugins/resetter/plugin.go b/plugins/resetter/plugin.go
index 43382e56..a80c2c0f 100644
--- a/plugins/resetter/plugin.go
+++ b/plugins/resetter/plugin.go
@@ -74,6 +74,11 @@ func (p *Plugin) Name() string {
return PluginName
}
+// Available interface implementation
+func (p *Plugin) Available() bool {
+ return true
+}
+
// RPC returns associated rpc service.
func (p *Plugin) RPC() interface{} {
return &rpc{srv: p, log: p.log}
diff --git a/plugins/rpc/plugin.go b/plugins/rpc/plugin.go
index b80994d3..f88aa6de 100644
--- a/plugins/rpc/plugin.go
+++ b/plugins/rpc/plugin.go
@@ -122,6 +122,11 @@ func (s *Plugin) Name() string {
return PluginName
}
+// Available interface implementation
+func (s *Plugin) Available() bool {
+ return true
+}
+
// Collects all plugins which implement Name + RPCer interfaces
func (s *Plugin) Collects() []interface{} {
return []interface{}{
diff --git a/plugins/server/plugin.go b/plugins/server/plugin.go
index c3496ae7..64793034 100644
--- a/plugins/server/plugin.go
+++ b/plugins/server/plugin.go
@@ -58,6 +58,11 @@ func (server *Plugin) Name() string {
return PluginName
}
+// Available interface implementation
+func (server *Plugin) Available() bool {
+ return true
+}
+
// Serve (Start) server plugin (just a mock here to satisfy interface)
func (server *Plugin) Serve() chan error {
const op = errors.Op("server_plugin_serve")
diff --git a/plugins/service/plugin.go b/plugins/service/plugin.go
index b5608ff2..522fe192 100644
--- a/plugins/service/plugin.go
+++ b/plugins/service/plugin.go
@@ -104,3 +104,8 @@ func (service *Plugin) Stop() error {
func (service *Plugin) Name() string {
return PluginName
}
+
+// Available interface implementation
+func (service *Plugin) Available() bool {
+ return true
+}
diff --git a/plugins/status/plugin.go b/plugins/status/plugin.go
index dc4e506d..3553bb01 100644
--- a/plugins/status/plugin.go
+++ b/plugins/status/plugin.go
@@ -127,7 +127,12 @@ func (c *Plugin) Name() string {
return PluginName
}
-// RPCService returns associated rpc service.
+// Available interface implementation
+func (c *Plugin) Available() bool {
+ return true
+}
+
+// RPC returns associated rpc service.
func (c *Plugin) RPC() interface{} {
return &rpc{srv: c, log: c.log}
}