diff options
author | Wolfy-J <[email protected]> | 2018-09-07 23:26:26 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-09-07 23:26:26 +0300 |
commit | cac8bf48bab69ff3468cf7d30ac1c18904885a47 (patch) | |
tree | 5ffec205a9b51a933339d535de198a267be0275a /service/rpc | |
parent | ea97c188a4a74c00b585cb50fa1ed4db7d190e09 (diff) |
added ability to alter env values
Diffstat (limited to 'service/rpc')
-rw-r--r-- | service/rpc/service.go | 16 |
1 files changed, 13 insertions, 3 deletions
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 } |