summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-09-10 14:29:10 +0300
committerWolfy-J <[email protected]>2018-09-10 14:29:10 +0300
commit7ab1e77f2db902cf8a485e3a28bfdbd58a613dc9 (patch)
tree748253cb7d5b758a0b61ab4a88023e5fed4f4a3b
parentceb5033d5bb2fb641c886d4010f05498552152c2 (diff)
go fmt
-rw-r--r--cmd/rr/http/debug.go6
-rw-r--r--cmd/rr/main.go2
-rw-r--r--git0
-rw-r--r--server_config.go19
-rw-r--r--service/env/environment.go2
-rw-r--r--service/env/service_test.go7
-rw-r--r--service/http/service_test.go2
-rw-r--r--service/rpc/service.go3
-rw-r--r--service/rpc/service_test.go8
-rw-r--r--service/static/config.go2
10 files changed, 35 insertions, 16 deletions
diff --git a/cmd/rr/http/debug.go b/cmd/rr/http/debug.go
index cae10452..f69e10a8 100644
--- a/cmd/rr/http/debug.go
+++ b/cmd/rr/http/debug.go
@@ -4,11 +4,11 @@ import (
rr "github.com/spiral/roadrunner/cmd/rr/cmd"
"github.com/spf13/cobra"
- "github.com/spiral/roadrunner/service/http"
"github.com/spiral/roadrunner/cmd/rr/debug"
+ "github.com/spiral/roadrunner/service/http"
)
-func init(){
+func init() {
cobra.OnInitialize(func() {
if rr.Debug {
svc, _ := rr.Container.Get(http.ID)
@@ -17,4 +17,4 @@ func init(){
}
}
})
-} \ No newline at end of file
+}
diff --git a/cmd/rr/main.go b/cmd/rr/main.go
index da34a62b..18e22cdd 100644
--- a/cmd/rr/main.go
+++ b/cmd/rr/main.go
@@ -23,8 +23,8 @@
package main
import (
- rr "github.com/spiral/roadrunner/cmd/rr/cmd"
"github.com/sirupsen/logrus"
+ rr "github.com/spiral/roadrunner/cmd/rr/cmd"
// services (plugins)
"github.com/spiral/roadrunner/service/env"
diff --git a/git b/git
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/git
diff --git a/server_config.go b/server_config.go
index 1a24e335..51f8245b 100644
--- a/server_config.go
+++ b/server_config.go
@@ -35,6 +35,10 @@ type ServerConfig struct {
// SetDefaults sets missing values to their default values.
func (cfg *ServerConfig) SetDefaults() {
+ if c.Workers.Relay == "" {
+ c.Workers.Relay = "pipes"
+ }
+
if cfg.RelayTimeout == 0 {
cfg.RelayTimeout = time.Minute
}
@@ -48,6 +52,21 @@ func (cfg *ServerConfig) SetDefaults() {
}
}
+// UpscaleDurations converts duration values from nanoseconds to seconds.
+func (cfg *ServerConfig) UpscaleDurations() {
+ if cfg.RelayTimeout < time.Microsecond {
+ cfg.RelayTimeout = time.Second * time.Duration(cfg.RelayTimeout.Nanoseconds())
+ }
+
+ if cfg.Pool.AllocateTimeout < time.Microsecond {
+ cfg.Pool.AllocateTimeout = time.Second * time.Duration(cfg.Pool.AllocateTimeout.Nanoseconds())
+ }
+
+ if cfg.Pool.DestroyTimeout < time.Microsecond {
+ cfg.Pool.DestroyTimeout = time.Second * time.Duration(cfg.Pool.DestroyTimeout.Nanoseconds())
+ }
+}
+
// Differs returns true if configuration has changed but ignores pool or cmd changes.
func (cfg *ServerConfig) Differs(new *ServerConfig) bool {
return cfg.Relay != new.Relay || cfg.RelayTimeout != new.RelayTimeout
diff --git a/service/env/environment.go b/service/env/environment.go
index d095009c..8e89d2c8 100644
--- a/service/env/environment.go
+++ b/service/env/environment.go
@@ -8,4 +8,4 @@ type Environment interface {
// SetEnv sets or creates environment value.
SetEnv(key, value string)
-} \ No newline at end of file
+}
diff --git a/service/env/service_test.go b/service/env/service_test.go
index 10159857..5b148207 100644
--- a/service/env/service_test.go
+++ b/service/env/service_test.go
@@ -23,15 +23,14 @@ func Test_Extend(t *testing.T) {
assert.Equal(t, "value", values["key"])
}
-
func Test_Set(t *testing.T) {
s := NewService(map[string]string{"rr": "version"})
s.Init(&Config{Values: map[string]string{"key": "value"}})
assert.Len(t, s.values, 2)
- s.SetEnv("key","value-new")
- s.SetEnv("other","new")
+ s.SetEnv("key", "value-new")
+ s.SetEnv("other", "new")
values, err := s.GetEnv()
assert.NoError(t, err)
@@ -39,4 +38,4 @@ func Test_Set(t *testing.T) {
assert.Equal(t, "version", values["rr"])
assert.Equal(t, "value-new", values["key"])
assert.Equal(t, "new", values["other"])
-} \ No newline at end of file
+}
diff --git a/service/http/service_test.go b/service/http/service_test.go
index 4e572335..9a5a3a9b 100644
--- a/service/http/service_test.go
+++ b/service/http/service_test.go
@@ -6,6 +6,7 @@ import (
"github.com/sirupsen/logrus/hooks/test"
"github.com/spiral/roadrunner"
"github.com/spiral/roadrunner/service"
+ "github.com/spiral/roadrunner/service/env"
"github.com/spiral/roadrunner/service/rpc"
"github.com/stretchr/testify/assert"
"io/ioutil"
@@ -13,7 +14,6 @@ import (
"os"
"testing"
"time"
- "github.com/spiral/roadrunner/service/env"
)
type testCfg struct {
diff --git a/service/rpc/service.go b/service/rpc/service.go
index 9cd32755..14e34319 100644
--- a/service/rpc/service.go
+++ b/service/rpc/service.go
@@ -3,9 +3,9 @@ package rpc
import (
"errors"
"github.com/spiral/goridge"
+ "github.com/spiral/roadrunner/service/env"
"net/rpc"
"sync"
- "github.com/spiral/roadrunner/service/env"
)
const (
@@ -16,6 +16,7 @@ const (
// rpc server connection.
EnvKey = "RR_RPC"
)
+
// Service is RPC service.
type Service struct {
cfg *Config
diff --git a/service/rpc/service_test.go b/service/rpc/service_test.go
index e47e9cdd..59e0e05d 100644
--- a/service/rpc/service_test.go
+++ b/service/rpc/service_test.go
@@ -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"},nil)
+ 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"},nil)
+ 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"},nil)
+ 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"},nil)
+ ok, err := s.Init(&Config{Enable: true, Listen: "tcp://localhost:9018"}, nil)
assert.NoError(t, err)
assert.True(t, ok)
diff --git a/service/static/config.go b/service/static/config.go
index 0ec1c8d8..be0ac3ed 100644
--- a/service/static/config.go
+++ b/service/static/config.go
@@ -1,11 +1,11 @@
package static
import (
+ "fmt"
"github.com/spiral/roadrunner/service"
"os"
"path"
"strings"
- "fmt"
)
// Config describes file location and controls access to them.