diff options
author | Wolfy-J <[email protected]> | 2018-09-10 14:28:15 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-09-10 14:28:15 +0300 |
commit | ceb5033d5bb2fb641c886d4010f05498552152c2 (patch) | |
tree | 5f5669d863a66a2e527ab0a51ede412e05a4cb16 /service | |
parent | 569a0dec066ea53fd6d0a2080362db67fd794557 (diff) |
minor config improvements
Diffstat (limited to 'service')
-rw-r--r-- | service/http/config.go | 24 | ||||
-rw-r--r-- | service/rpc/service_test.go | 10 |
2 files changed, 8 insertions, 26 deletions
diff --git a/service/http/config.go b/service/http/config.go index a15edb35..2cfe1ba2 100644 --- a/service/http/config.go +++ b/service/http/config.go @@ -5,7 +5,6 @@ import ( "github.com/spiral/roadrunner" "github.com/spiral/roadrunner/service" "strings" - "time" ) // Config configures RoadRunner HTTP server. @@ -36,30 +35,13 @@ func (c *Config) Hydrate(cfg service.Config) error { return nil } + c.Workers.SetDefaults() + c.Workers.UpscaleDurations() + if err := c.Valid(); err != nil { return err } - if c.Workers.Relay == "" { - c.Workers.Relay = "pipes" - } - - c.Workers.MountDefaults() - - // nanosecond to second conversion - - if c.Workers.RelayTimeout < time.Microsecond { - c.Workers.RelayTimeout = time.Second * time.Duration(c.Workers.RelayTimeout.Nanoseconds()) - } - - if c.Workers.Pool.AllocateTimeout < time.Microsecond { - c.Workers.Pool.AllocateTimeout = time.Second * time.Duration(c.Workers.Pool.AllocateTimeout.Nanoseconds()) - } - - if c.Workers.Pool.DestroyTimeout < time.Microsecond { - c.Workers.Pool.DestroyTimeout = time.Second * time.Duration(c.Workers.Pool.DestroyTimeout.Nanoseconds()) - } - return nil } diff --git a/service/rpc/service_test.go b/service/rpc/service_test.go index fc88d38d..e47e9cdd 100644 --- a/service/rpc/service_test.go +++ b/service/rpc/service_test.go @@ -12,7 +12,7 @@ func (ts *testService) Echo(msg string, r *string) error { *r = msg; return nil func Test_Disabled(t *testing.T) { s := &Service{} - ok, err := s.Init(&Config{Enable: false}) + ok, err := s.Init(&Config{Enable: false}, nil) assert.NoError(t, err) assert.False(t, ok) @@ -30,7 +30,7 @@ func Test_RegisterNotConfigured(t *testing.T) { func Test_Enabled(t *testing.T) { s := &Service{} - ok, err := s.Init(&Config{Enable: true, Listen: "tcp://localhost:9008"}) + ok, err := s.Init(&Config{Enable: true, Listen: "tcp://localhost:9008"},nil) assert.NoError(t, err) assert.True(t, ok) @@ -38,7 +38,7 @@ func Test_Enabled(t *testing.T) { func Test_StopNonServing(t *testing.T) { s := &Service{} - ok, err := s.Init(&Config{Enable: true, Listen: "tcp://localhost:9008"}) + ok, err := s.Init(&Config{Enable: true, Listen: "tcp://localhost:9008"},nil) assert.NoError(t, err) assert.True(t, ok) @@ -47,7 +47,7 @@ func Test_StopNonServing(t *testing.T) { func Test_Serve_Errors(t *testing.T) { s := &Service{} - ok, err := s.Init(&Config{Enable: true, Listen: "mailformed"}) + ok, err := s.Init(&Config{Enable: true, Listen: "mailformed"},nil) assert.NoError(t, err) assert.True(t, ok) @@ -60,7 +60,7 @@ func Test_Serve_Errors(t *testing.T) { func Test_Serve_Client(t *testing.T) { s := &Service{} - ok, err := s.Init(&Config{Enable: true, Listen: "tcp://localhost:9018"}) + ok, err := s.Init(&Config{Enable: true, Listen: "tcp://localhost:9018"},nil) assert.NoError(t, err) assert.True(t, ok) |