summaryrefslogtreecommitdiff
path: root/service
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 /service
parent2afa417f4f46b31b79043e3e56513d51e4ad2fde (diff)
golint
Diffstat (limited to 'service')
-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
9 files changed, 39 insertions, 19 deletions
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