diff options
author | Valery Piashchynski <[email protected]> | 2021-01-13 15:30:54 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-13 15:30:54 +0300 |
commit | 2a1c6092056c9dc1d725e393da97b72eb65071c4 (patch) | |
tree | 362f0eacdf2373bf208441577c1e69b8337bd71e /plugins/rpc/plugin.go | |
parent | f0f2b1aaf8e4df2ab65c6c47d9183f072ac86841 (diff) | |
parent | 2eed81d8fdbf8ee5134bb3b3f4c11c63cf6d757c (diff) |
Merge pull request #473 from spiral/feature/env_variables
feat(env): Add RR system environment variables
Diffstat (limited to 'plugins/rpc/plugin.go')
-rw-r--r-- | plugins/rpc/plugin.go | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/plugins/rpc/plugin.go b/plugins/rpc/plugin.go index 6a83326b..c5813e7b 100644 --- a/plugins/rpc/plugin.go +++ b/plugins/rpc/plugin.go @@ -22,17 +22,18 @@ type pluggable struct { // Plugin is RPC service. type Plugin struct { - cfg Config - log logger.Logger - rpc *rpc.Server - services []pluggable + cfg Config + log logger.Logger + rpc *rpc.Server + // set of the plugins, which are implement RPCer interface and can be plugged into the RR via RPC + plugins []pluggable listener net.Listener closed *uint32 } // Init rpc service. Must return true if service is enabled. func (s *Plugin) Init(cfg config.Configurer, log logger.Logger) error { - const op = errors.Op("RPC plugin init") + const op = errors.Op("rpc plugin init") if !cfg.Has(PluginName) { return errors.E(op, errors.Disabled) } @@ -43,10 +44,6 @@ func (s *Plugin) Init(cfg config.Configurer, log logger.Logger) error { } s.cfg.InitDefaults() - if s.cfg.Disabled { - return errors.E(op, errors.Disabled) - } - s.log = log state := uint32(0) s.closed = &state @@ -57,22 +54,22 @@ func (s *Plugin) Init(cfg config.Configurer, log logger.Logger) error { // Serve serves the service. func (s *Plugin) Serve() chan error { - const op = errors.Op("register service") + const op = errors.Op("serve rpc plugin") errCh := make(chan error, 1) s.rpc = rpc.NewServer() - services := make([]string, 0, len(s.services)) + services := make([]string, 0, len(s.plugins)) // Attach all services - for i := 0; i < len(s.services); i++ { - err := s.Register(s.services[i].name, s.services[i].service.RPC()) + for i := 0; i < len(s.plugins); i++ { + err := s.Register(s.plugins[i].name, s.plugins[i].service.RPC()) if err != nil { errCh <- errors.E(op, err) return errCh } - services = append(services, s.services[i].name) + services = append(services, s.plugins[i].name) } var err error @@ -131,7 +128,7 @@ func (s *Plugin) Collects() []interface{} { // RegisterPlugin registers RPC service plugin. func (s *Plugin) RegisterPlugin(name endure.Named, p RPCer) { - s.services = append(s.services, pluggable{ + s.plugins = append(s.plugins, pluggable{ service: p, name: name.Name(), }) |