diff options
Diffstat (limited to 'service')
-rw-r--r-- | service/http/handler.go | 2 | ||||
-rw-r--r-- | service/http/service.go | 32 | ||||
-rw-r--r-- | service/limit/config.go (renamed from service/watcher/config.go) | 2 | ||||
-rw-r--r-- | service/limit/controller.go (renamed from service/watcher/controller.go) | 2 | ||||
-rw-r--r-- | service/limit/service.go (renamed from service/watcher/service.go) | 16 | ||||
-rw-r--r-- | service/limit/state_filter.go (renamed from service/watcher/state_filter.go) | 2 |
6 files changed, 28 insertions, 28 deletions
diff --git a/service/http/handler.go b/service/http/handler.go index 280d67aa..254f5ca6 100644 --- a/service/http/handler.go +++ b/service/http/handler.go @@ -63,7 +63,7 @@ type Handler struct { lsn func(event int, ctx interface{}) } -// Listen attaches handler event watcher. +// Listen attaches handler event controller. func (h *Handler) Listen(l func(event int, ctx interface{})) { h.mul.Lock() defer h.mul.Unlock() diff --git a/service/http/service.go b/service/http/service.go index b76d8893..1239acca 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -27,21 +27,21 @@ type middleware func(f http.HandlerFunc) http.HandlerFunc // Services manages rr, http servers. type Service struct { - cfg *Config - env env.Environment - lsns []func(event int, ctx interface{}) - mdwr []middleware - mu sync.Mutex - rr *roadrunner.Server - watcher roadrunner.Controller - handler *Handler - http *http.Server - https *http.Server + cfg *Config + env env.Environment + lsns []func(event int, ctx interface{}) + mdwr []middleware + mu sync.Mutex + rr *roadrunner.Server + controller roadrunner.Controller + handler *Handler + http *http.Server + https *http.Server } -// Watch attaches watcher. -func (s *Service) Watch(w roadrunner.Controller) { - s.watcher = w +// AddController attaches controller. Currently only one controller is supported. +func (s *Service) AddController(w roadrunner.Controller) { + s.controller = w } // AddMiddleware adds new net/http mdwr. @@ -49,7 +49,7 @@ func (s *Service) AddMiddleware(m middleware) { s.mdwr = append(s.mdwr, m) } -// AddListener attaches server event watcher. +// AddListener attaches server event controller. func (s *Service) AddListener(l func(event int, ctx interface{})) { s.lsns = append(s.lsns, l) } @@ -84,8 +84,8 @@ func (s *Service) Serve() error { s.rr = roadrunner.NewServer(s.cfg.Workers) s.rr.Listen(s.throw) - if s.watcher != nil { - s.rr.Watch(s.watcher) + if s.controller != nil { + s.rr.Watch(s.controller) } s.handler = &Handler{cfg: s.cfg, rr: s.rr} diff --git a/service/watcher/config.go b/service/limit/config.go index 8151005d..bf842ac2 100644 --- a/service/watcher/config.go +++ b/service/limit/config.go @@ -1,4 +1,4 @@ -package watcher +package limit import ( "github.com/spiral/roadrunner" diff --git a/service/watcher/controller.go b/service/limit/controller.go index 38eddf84..bdbab003 100644 --- a/service/watcher/controller.go +++ b/service/limit/controller.go @@ -1,4 +1,4 @@ -package watcher +package limit import ( "fmt" diff --git a/service/watcher/service.go b/service/limit/service.go index 3db23b68..72673d1f 100644 --- a/service/watcher/service.go +++ b/service/limit/service.go @@ -1,4 +1,4 @@ -package watcher +package limit import ( "github.com/spiral/roadrunner" @@ -6,12 +6,12 @@ import ( ) // ID defines controller service name. -const ID = "control" +const ID = "constrain" -// Watchable defines the ability to attach rr controller. -type Watchable interface { - // Watch attaches controller to the service. - Watch(w roadrunner.Controller) +// Controllable defines the ability to attach rr controller. +type Controllable interface { + // AddController attaches controller to the service. + AddController(c roadrunner.Controller) } // Services to control the state of rr service inside other services. @@ -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 watchable, ok := svc.(Watchable); ok { - watchable.Watch(watcher) + if ctrl, ok := svc.(Controllable); ok { + ctrl.AddController(watcher) } } diff --git a/service/watcher/state_filter.go b/service/limit/state_filter.go index d85f1308..cd2eca94 100644 --- a/service/watcher/state_filter.go +++ b/service/limit/state_filter.go @@ -1,4 +1,4 @@ -package watcher +package limit import ( "github.com/spiral/roadrunner" |