diff options
author | Wolfy-J <[email protected]> | 2018-06-13 14:07:05 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-13 14:07:05 +0300 |
commit | ca95f67317bcf8972b9e669869338a7dc09bf06d (patch) | |
tree | 4d199ceb8a78675242fef21bd87efb5a78b04029 | |
parent | c8e8afe79611941ce50453ee7dfae82d7915e9c4 (diff) |
more upload tests
-rw-r--r-- | service/container.go | 4 | ||||
-rw-r--r-- | service/http/service.go | 26 | ||||
-rw-r--r-- | service/rpc/service.go | 4 | ||||
-rw-r--r-- | service/rpc/service_test.go | 12 | ||||
-rw-r--r-- | service/service.go | 4 | ||||
-rw-r--r-- | service/static/service.go | 4 |
6 files changed, 27 insertions, 27 deletions
diff --git a/service/container.go b/service/container.go index 56350be7..7c7633e7 100644 --- a/service/container.go +++ b/service/container.go @@ -95,7 +95,7 @@ func (c *container) Get(target string) (svc Service, status int) { return nil, StatusUndefined } -// Configure configures all underlying services with given configuration. +// Init configures all underlying services with given configuration. func (c *container) Configure(cfg Config) error { for _, e := range c.services { if e.getStatus() >= StatusConfigured { @@ -108,7 +108,7 @@ func (c *container) Configure(cfg Config) error { continue } - ok, err := e.svc.Configure(segment, c) + ok, err := e.svc.Init(segment, c) if err != nil { return errors.Wrap(err, fmt.Sprintf("[%s]", e.name)) } else if ok { diff --git a/service/http/service.go b/service/http/service.go index dc89c188..f1712fd2 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -12,22 +12,22 @@ import ( const Name = "http" type middleware interface { - // Handle must return true if request/response pair is handled withing the middleware. + // Handle must return true if request/response pair is handled withing the mdws. Handle(w http.ResponseWriter, r *http.Request) bool } // Service manages rr, http servers. type Service struct { - cfg *Config - lsns []func(event int, ctx interface{}) - rr *roadrunner.Server - middleware []middleware - srv *Handler - http *http.Server + cfg *Config + lsns []func(event int, ctx interface{}) + rr *roadrunner.Server + mdws []middleware + srv *Handler + http *http.Server } func (s *Service) AddMiddleware(m middleware) { - s.middleware = append(s.middleware, m) + s.mdws = append(s.mdws, m) } // AddListener attaches server event watcher. @@ -35,9 +35,9 @@ func (s *Service) AddListener(l func(event int, ctx interface{})) { s.lsns = append(s.lsns, l) } -// Configure must return configure svc and return true if svc hasStatus enabled. Must return error in case of +// Init must return configure svc and return true if svc hasStatus enabled. Must return error in case of // misconfiguration. Services must not be used without proper configuration pushed first. -func (s *Service) Configure(cfg service.Config, c service.Container) (bool, error) { +func (s *Service) Init(cfg service.Config, c service.Container) (bool, error) { config := &Config{} if err := cfg.Unmarshal(config); err != nil { return false, err @@ -74,7 +74,7 @@ func (s *Service) Serve() error { s.rr.Listen(s.listener) s.srv.Listen(s.listener) - if len(s.middleware) == 0 { + if len(s.mdws) == 0 { s.http.Handler = s.srv } else { s.http.Handler = s @@ -101,9 +101,9 @@ func (s *Service) Stop() { s.http.Shutdown(context.Background()) } -// Handle handles connection using set of middleware and rr PSR-7 server. +// Handle handles connection using set of mdws and rr PSR-7 server. func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) { - for _, m := range s.middleware { + for _, m := range s.mdws { if m.Handle(w, r) { return } diff --git a/service/rpc/service.go b/service/rpc/service.go index ce1e3351..6e26d3c2 100644 --- a/service/rpc/service.go +++ b/service/rpc/service.go @@ -21,9 +21,9 @@ type Service struct { serving bool } -// Configure must return configure service and return true if service hasStatus enabled. Must return error in case of +// Init must return configure service and return true if service hasStatus enabled. Must return error in case of // misconfiguration. Services must not be used without proper configuration pushed first. -func (s *Service) Configure(cfg service.Config, reg service.Container) (enabled bool, err error) { +func (s *Service) Init(cfg service.Config, reg service.Container) (enabled bool, err error) { config := &config{} if err := cfg.Unmarshal(config); err != nil { return false, err diff --git a/service/rpc/service_test.go b/service/rpc/service_test.go index f6aeb2aa..ce85d52f 100644 --- a/service/rpc/service_test.go +++ b/service/rpc/service_test.go @@ -19,7 +19,7 @@ func (cfg *testCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]b func Test_ConfigError(t *testing.T) { s := &Service{} - ok, err := s.Configure(&testCfg{`{"enable":false`}, nil) + ok, err := s.Init(&testCfg{`{"enable":false`}, nil) assert.Error(t, err) assert.False(t, ok) @@ -27,7 +27,7 @@ func Test_ConfigError(t *testing.T) { func Test_Disabled(t *testing.T) { s := &Service{} - ok, err := s.Configure(&testCfg{`{"enable":false}`}, nil) + ok, err := s.Init(&testCfg{`{"enable":false}`}, nil) assert.NoError(t, err) assert.False(t, ok) @@ -45,7 +45,7 @@ func Test_RegisterNotConfigured(t *testing.T) { func Test_Enabled(t *testing.T) { s := &Service{} - ok, err := s.Configure(&testCfg{`{"enable":true, "listen":"tcp://localhost:9008"}`}, nil) + ok, err := s.Init(&testCfg{`{"enable":true, "listen":"tcp://localhost:9008"}`}, nil) assert.NoError(t, err) assert.True(t, ok) @@ -53,7 +53,7 @@ func Test_Enabled(t *testing.T) { func Test_StopNonServing(t *testing.T) { s := &Service{} - ok, err := s.Configure(&testCfg{`{"enable":true, "listen":"tcp://localhost:9008"}`}, nil) + ok, err := s.Init(&testCfg{`{"enable":true, "listen":"tcp://localhost:9008"}`}, nil) assert.NoError(t, err) assert.True(t, ok) @@ -62,7 +62,7 @@ func Test_StopNonServing(t *testing.T) { func Test_Serve_Errors(t *testing.T) { s := &Service{} - ok, err := s.Configure(&testCfg{`{"enable":true, "listen":"mailformed"}`}, nil) + ok, err := s.Init(&testCfg{`{"enable":true, "listen":"mailformed"}`}, nil) assert.NoError(t, err) assert.True(t, ok) @@ -75,7 +75,7 @@ func Test_Serve_Errors(t *testing.T) { func Test_Serve_Client(t *testing.T) { s := &Service{} - ok, err := s.Configure(&testCfg{`{"enable":true, "listen":"tcp://localhost:9018"}`}, nil) + ok, err := s.Init(&testCfg{`{"enable":true, "listen":"tcp://localhost:9018"}`}, nil) assert.NoError(t, err) assert.True(t, ok) diff --git a/service/service.go b/service/service.go index 7ddfbd7a..6ddcda41 100644 --- a/service/service.go +++ b/service/service.go @@ -4,9 +4,9 @@ import "sync" // svc provides high level functionality for road runner svc. type Service interface { - // Configure must return configure service and return true if service hasStatus enabled. Must return error in case of + // Init must return configure service and return true if service hasStatus enabled. Must return error in case of // misconfiguration. Services must not be used without proper configuration pushed first. - Configure(cfg Config, c Container) (enabled bool, err error) + Init(cfg Config, c Container) (enabled bool, err error) // Serve serves. Serve() error diff --git a/service/static/service.go b/service/static/service.go index 5c3defe6..5f7d31f0 100644 --- a/service/static/service.go +++ b/service/static/service.go @@ -20,9 +20,9 @@ type Service struct { root http.Dir } -// Configure must return configure service and return true if service hasStatus enabled. Must return error in case of +// Init must return configure service and return true if service hasStatus enabled. Must return error in case of // misconfiguration. Services must not be used without proper configuration pushed first. -func (s *Service) Configure(cfg service.Config, c service.Container) (enabled bool, err error) { +func (s *Service) Init(cfg service.Config, c service.Container) (enabled bool, err error) { config := &Config{} if err := cfg.Unmarshal(config); err != nil { return false, err |