summaryrefslogtreecommitdiff
path: root/plugins/resetter
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-15 17:59:20 +0300
committerValery Piashchynski <[email protected]>2020-12-15 17:59:20 +0300
commit089a202aa716f3510402ff8baf47a3b9bfaefcb8 (patch)
treec0d889ab896804da239dd3e1bd16de0bdd70e379 /plugins/resetter
parent21b51367e27f5a1b166459a115e4655d07a5d832 (diff)
Update reloader to support new container
Diffstat (limited to 'plugins/resetter')
-rw-r--r--plugins/resetter/plugin.go33
-rw-r--r--plugins/resetter/rpc.go4
2 files changed, 32 insertions, 5 deletions
diff --git a/plugins/resetter/plugin.go b/plugins/resetter/plugin.go
index 99e02aef..8dc5cc31 100644
--- a/plugins/resetter/plugin.go
+++ b/plugins/resetter/plugin.go
@@ -10,12 +10,39 @@ import (
const PluginName = "resetter"
type Plugin struct {
- registry map[string]resetter.Resetter
+ registry map[string]resetter.Resettable
log log.Logger
}
+func (p *Plugin) ResetAll() error {
+ const op = errors.Op("reset all")
+ for name := range p.registry {
+ err := p.registry[name].Reset()
+ if err != nil {
+ return errors.E(op, err)
+ }
+ }
+ return nil
+}
+
+func (p *Plugin) ResetByName(plugin string) error {
+ const op = errors.Op("reset by name")
+ if plugin, ok := p.registry[plugin]; ok {
+ return plugin.Reset()
+ }
+ return errors.E(op, errors.Errorf("can't find plugin: %s", plugin))
+}
+
+func (p *Plugin) GetAll() []string {
+ all := make([]string, 0, len(p.registry))
+ for name := range p.registry {
+ all = append(all, name)
+ }
+ return all
+}
+
func (p *Plugin) Init(log log.Logger) error {
- p.registry = make(map[string]resetter.Resetter)
+ p.registry = make(map[string]resetter.Resettable)
p.log = log
return nil
}
@@ -31,7 +58,7 @@ func (p *Plugin) Reset(name string) error {
}
// RegisterTarget resettable service.
-func (p *Plugin) RegisterTarget(name endure.Named, r resetter.Resetter) error {
+func (p *Plugin) RegisterTarget(name endure.Named, r resetter.Resettable) error {
p.registry[name.Name()] = r
return nil
}
diff --git a/plugins/resetter/rpc.go b/plugins/resetter/rpc.go
index ecc51bb3..344c6681 100644
--- a/plugins/resetter/rpc.go
+++ b/plugins/resetter/rpc.go
@@ -7,7 +7,7 @@ type rpc struct {
log log.Logger
}
-// List all resettable services.
+// List all resettable plugins.
func (rpc *rpc) List(_ bool, list *[]string) error {
rpc.log.Debug("started List method")
*list = make([]string, 0)
@@ -21,7 +21,7 @@ func (rpc *rpc) List(_ bool, list *[]string) error {
return nil
}
-// Reset named service.
+// Reset named plugin.
func (rpc *rpc) Reset(service string, done *bool) error {
rpc.log.Debug("started Reset method for the service", "service", service)
defer rpc.log.Debug("finished Reset method for the service", "service", service)