diff options
Diffstat (limited to 'service/rpc/service.go')
-rw-r--r-- | service/rpc/service.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/service/rpc/service.go b/service/rpc/service.go index 6e231048..3ea6c5fc 100644 --- a/service/rpc/service.go +++ b/service/rpc/service.go @@ -3,12 +3,19 @@ package rpc import ( "errors" "github.com/spiral/goridge" + "github.com/spiral/roadrunner/service/env" "net/rpc" "sync" ) -// ID contains default service name. -const ID = "rpc" +const ( + // ID contains default service name. + ID = "rpc" + + // rrKey defines environment key to be used to store information about + // rpc server connection. + envKey = "rr_rpc" +) // Service is RPC service. type Service struct { @@ -20,7 +27,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 +35,10 @@ func (s *Service) Init(cfg *Config) (bool, error) { s.cfg = cfg s.rpc = rpc.NewServer() + if env != nil { + env.SetEnv(envKey, cfg.Listen) + } + return true, nil } |