From cac8bf48bab69ff3468cf7d30ac1c18904885a47 Mon Sep 17 00:00:00 2001 From: Wolfy-J Date: Fri, 7 Sep 2018 23:26:26 +0300 Subject: added ability to alter env values --- service/rpc/service.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'service/rpc') diff --git a/service/rpc/service.go b/service/rpc/service.go index 6e231048..abeae240 100644 --- a/service/rpc/service.go +++ b/service/rpc/service.go @@ -5,11 +5,17 @@ import ( "github.com/spiral/goridge" "net/rpc" "sync" + "github.com/spiral/roadrunner/service/env" ) -// ID contains default service name. -const ID = "rpc" +const ( + // ID contains default service name. + ID = "rpc" + // ENV_KEY defines environment key to be used to store information about + // rpc server connection. + ENV_KEY = "RR_RPC" +) // Service is RPC service. type Service struct { cfg *Config @@ -20,7 +26,7 @@ type Service struct { } // Init rpc service. Must return true if service is enabled. -func (s *Service) Init(cfg *Config) (bool, error) { +func (s *Service) Init(cfg *Config, env env.Environment) (bool, error) { if !cfg.Enable { return false, nil } @@ -28,6 +34,10 @@ func (s *Service) Init(cfg *Config) (bool, error) { s.cfg = cfg s.rpc = rpc.NewServer() + if env != nil { + env.SetEnv(ENV_KEY, cfg.Listen) + } + return true, nil } -- cgit v1.2.3