summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2019-05-04 23:07:30 +0300
committerWolfy-J <[email protected]>2019-05-04 23:07:30 +0300
commit3800c27ff9ec2641248d6dc2ce2f7ab56c237664 (patch)
treec8026df76f0fea5519f958d310210e1da46f369d
parent2afa417f4f46b31b79043e3e56513d51e4ad2fde (diff)
golint
-rw-r--r--controller_test.go10
-rw-r--r--server.go6
-rw-r--r--service/env/service.go2
-rw-r--r--service/http/service.go10
-rw-r--r--service/http/uploads_config.go2
-rw-r--r--service/limit/config.go2
-rw-r--r--service/limit/config_test.go20
-rw-r--r--service/limit/controller.go2
-rw-r--r--service/limit/service.go14
-rw-r--r--service/rpc/service.go4
-rw-r--r--service/static/service.go2
-rw-r--r--worker.go2
12 files changed, 48 insertions, 28 deletions
diff --git a/controller_test.go b/controller_test.go
index 031c2f31..d177feda 100644
--- a/controller_test.go
+++ b/controller_test.go
@@ -47,7 +47,7 @@ func Test_WatcherWatch(t *testing.T) {
})
defer rr.Stop()
- rr.Watch(&eWatcher{})
+ rr.Attach(&eWatcher{})
assert.NoError(t, rr.Start())
assert.NotNil(t, rr.pController)
@@ -76,7 +76,7 @@ func Test_WatcherReattach(t *testing.T) {
})
defer rr.Stop()
- rr.Watch(&eWatcher{})
+ rr.Attach(&eWatcher{})
assert.NoError(t, rr.Start())
assert.NotNil(t, rr.pController)
@@ -115,7 +115,7 @@ func Test_WatcherAttachDetachSequence(t *testing.T) {
var attachedPool Pool
- rr.Watch(&eWatcher{
+ rr.Attach(&eWatcher{
onAttach: func(p Pool) {
attachedPool = p
},
@@ -151,7 +151,7 @@ func Test_RemoveWorkerOnAllocation(t *testing.T) {
})
defer rr.Stop()
- rr.Watch(&eWatcher{})
+ rr.Attach(&eWatcher{})
assert.NoError(t, rr.Start())
wr := rr.Workers()[0]
@@ -186,7 +186,7 @@ func Test_RemoveWorkerAfterTask(t *testing.T) {
})
defer rr.Stop()
- rr.Watch(&eWatcher{})
+ rr.Attach(&eWatcher{})
assert.NoError(t, rr.Start())
wr := rr.Workers()[0]
diff --git a/server.go b/server.go
index d1757207..8f8e9382 100644
--- a/server.go
+++ b/server.go
@@ -63,8 +63,8 @@ func (s *Server) Listen(l func(event int, ctx interface{})) {
s.lsn = l
}
-// AddController attaches worker controller.
-func (s *Server) Watch(c Controller) {
+// Attach attaches worker controller.
+func (s *Server) Attach(c Controller) {
s.mu.Lock()
defer s.mu.Unlock()
@@ -102,7 +102,7 @@ func (s *Server) Start() (err error) {
return nil
}
-// Detach underlying worker pool and close the factory.
+// Stop underlying worker pool and close the factory.
func (s *Server) Stop() {
s.mu.Lock()
defer s.mu.Unlock()
diff --git a/service/env/service.go b/service/env/service.go
index 00bc41ef..83175b36 100644
--- a/service/env/service.go
+++ b/service/env/service.go
@@ -3,7 +3,7 @@ package env
// ID contains default service name.
const ID = "env"
-// Services provides ability to map _ENV values from config file.
+// Service provides ability to map _ENV values from config file.
type Service struct {
// values is default set of values.
values map[string]string
diff --git a/service/http/service.go b/service/http/service.go
index 1239acca..8105d218 100644
--- a/service/http/service.go
+++ b/service/http/service.go
@@ -25,7 +25,7 @@ const (
// http middleware type.
type middleware func(f http.HandlerFunc) http.HandlerFunc
-// Services manages rr, http servers.
+// Service manages rr, http servers.
type Service struct {
cfg *Config
env env.Environment
@@ -39,8 +39,8 @@ type Service struct {
https *http.Server
}
-// AddController attaches controller. Currently only one controller is supported.
-func (s *Service) AddController(w roadrunner.Controller) {
+// Attach attaches controller. Currently only one controller is supported.
+func (s *Service) Attach(w roadrunner.Controller) {
s.controller = w
}
@@ -85,7 +85,7 @@ func (s *Service) Serve() error {
s.rr.Listen(s.throw)
if s.controller != nil {
- s.rr.Watch(s.controller)
+ s.rr.Attach(s.controller)
}
s.handler = &Handler{cfg: s.cfg, rr: s.rr}
@@ -113,7 +113,7 @@ func (s *Service) Serve() error {
return <-err
}
-// Detach stops the svc.
+// Stop stops the http.
func (s *Service) Stop() {
s.mu.Lock()
defer s.mu.Unlock()
diff --git a/service/http/uploads_config.go b/service/http/uploads_config.go
index 9f62d779..3f655064 100644
--- a/service/http/uploads_config.go
+++ b/service/http/uploads_config.go
@@ -31,7 +31,7 @@ func (cfg *UploadsConfig) TmpDir() string {
return os.TempDir()
}
-// AlwaysForbid must return true if file extension is not allowed for the upload.
+// Forbids must return true if file extension is not allowed for the upload.
func (cfg *UploadsConfig) Forbids(filename string) bool {
ext := strings.ToLower(path.Ext(filename))
diff --git a/service/limit/config.go b/service/limit/config.go
index bf842ac2..203db11b 100644
--- a/service/limit/config.go
+++ b/service/limit/config.go
@@ -6,7 +6,7 @@ import (
"time"
)
-// Configures set of Services.
+// Config of Limit service.
type Config struct {
// Interval defines the update duration for underlying controllers, default 1s.
Interval time.Duration
diff --git a/service/limit/config_test.go b/service/limit/config_test.go
new file mode 100644
index 00000000..aa793623
--- /dev/null
+++ b/service/limit/config_test.go
@@ -0,0 +1,20 @@
+package limit
+
+import (
+ "encoding/json"
+ "github.com/spiral/roadrunner/service"
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
+
+type mockCfg struct{ cfg string }
+
+func (cfg *mockCfg) Get(name string) service.Config { return nil }
+func (cfg *mockCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) }
+
+func Test_Config_Hydrate_Error1(t *testing.T) {
+ cfg := &mockCfg{`{"enable": true}`}
+ c := &Config{}
+
+ assert.Error(t, c.Hydrate(cfg))
+}
diff --git a/service/limit/controller.go b/service/limit/controller.go
index bdbab003..3e6aed4b 100644
--- a/service/limit/controller.go
+++ b/service/limit/controller.go
@@ -17,7 +17,7 @@ const (
// EventMaxIdleTTL triggered when worker spends too much time at rest.
EventMaxIdleTTL
- // EventMaxIdleTTL triggered when worker spends too much time doing the task (max_execution_time).
+ // EventMaxExecTTL triggered when worker spends too much time doing the task (max_execution_time).
EventMaxExecTTL
)
diff --git a/service/limit/service.go b/service/limit/service.go
index 72673d1f..99e2b1ee 100644
--- a/service/limit/service.go
+++ b/service/limit/service.go
@@ -8,13 +8,13 @@ import (
// ID defines controller service name.
const ID = "constrain"
-// Controllable defines the ability to attach rr controller.
-type Controllable interface {
- // AddController attaches controller to the service.
- AddController(c roadrunner.Controller)
+// controllable defines the ability to attach rr controller.
+type controllable interface {
+ // Attach attaches controller to the service.
+ Attach(c roadrunner.Controller)
}
-// Services to control the state of rr service inside other services.
+// Service to control the state of rr service inside other services.
type Service struct {
cfg *Config
lsns []func(event int, ctx interface{})
@@ -25,8 +25,8 @@ func (s *Service) Init(cfg *Config, c service.Container) (bool, error) {
// mount Services to designated services
for id, watcher := range cfg.Controllers(s.throw) {
svc, _ := c.Get(id)
- if ctrl, ok := svc.(Controllable); ok {
- ctrl.AddController(watcher)
+ if ctrl, ok := svc.(controllable); ok {
+ ctrl.Attach(watcher)
}
}
diff --git a/service/rpc/service.go b/service/rpc/service.go
index ea262615..eba74c2d 100644
--- a/service/rpc/service.go
+++ b/service/rpc/service.go
@@ -12,7 +12,7 @@ import (
// ID contains default service name.
const ID = "rpc"
-// Services is RPC service.
+// Service is RPC service.
type Service struct {
cfg *Config
stop chan interface{}
@@ -83,7 +83,7 @@ func (s *Service) Serve() error {
return nil
}
-// Detach stops the service.
+// Stop stops the service.
func (s *Service) Stop() {
s.mu.Lock()
defer s.mu.Unlock()
diff --git a/service/static/service.go b/service/static/service.go
index 679033f2..b824e787 100644
--- a/service/static/service.go
+++ b/service/static/service.go
@@ -9,7 +9,7 @@ import (
// ID contains default service name.
const ID = "static"
-// Services serves static files. Potentially convert into middleware?
+// Service serves static files. Potentially convert into middleware?
type Service struct {
// server configuration (location, forbidden files and etc)
cfg *Config
diff --git a/worker.go b/worker.go
index 88fd1b9b..ac0ba38e 100644
--- a/worker.go
+++ b/worker.go
@@ -127,7 +127,7 @@ func (w *Worker) Wait() error {
return &exec.ExitError{ProcessState: w.endState}
}
-// Detach sends soft termination command to the worker and waits for process completion.
+// Stop sends soft termination command to the worker and waits for process completion.
func (w *Worker) Stop() error {
select {
case <-w.waitDone: