summaryrefslogtreecommitdiff
path: root/service/rpc
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-09-07 23:26:26 +0300
committerWolfy-J <[email protected]>2018-09-07 23:26:26 +0300
commitcac8bf48bab69ff3468cf7d30ac1c18904885a47 (patch)
tree5ffec205a9b51a933339d535de198a267be0275a /service/rpc
parentea97c188a4a74c00b585cb50fa1ed4db7d190e09 (diff)
added ability to alter env values
Diffstat (limited to 'service/rpc')
-rw-r--r--service/rpc/service.go16
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
}