diff options
author | Valery Piashchynski <[email protected]> | 2021-01-13 11:11:36 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-01-13 11:11:36 +0300 |
commit | c3cf1d988b980e9408862d380f7ae33dae501e05 (patch) | |
tree | 79430ed15f75e23242e921a1471633e33279c395 /plugins/rpc | |
parent | 44b0ad21e0d70e413a62814fb408faa033b0d478 (diff) |
Update styly of the .rr.yaml
Add comments
Add support for the automatically set RR_RPC, RR_HTTP env variables for
the worker process.
Diffstat (limited to 'plugins/rpc')
-rw-r--r-- | plugins/rpc/config.go | 3 | ||||
-rw-r--r-- | plugins/rpc/plugin.go | 27 |
2 files changed, 12 insertions, 18 deletions
diff --git a/plugins/rpc/config.go b/plugins/rpc/config.go index d7531435..88ad7f0e 100644 --- a/plugins/rpc/config.go +++ b/plugins/rpc/config.go @@ -12,9 +12,6 @@ import ( type Config struct { // Listen string Listen string - - // Disabled disables RPC service. - Disabled bool } // InitDefaults allows to init blank config with pre-defined set of default values. 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(), }) |