diff options
author | Wolfy-J <[email protected]> | 2019-05-03 12:30:02 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2019-05-03 12:30:02 +0300 |
commit | 3454c00ac37a141d7bb8db6990d90606f1bb14b3 (patch) | |
tree | ec92ac8717b9efe80fe9b9eb21fbcf986e6443f0 /service | |
parent | 9b886ceab6a63e8264f2b2c9d35d76628085dbd6 (diff) |
added pool watcher capability
Diffstat (limited to 'service')
-rw-r--r-- | service/http/rpc.go | 4 | ||||
-rw-r--r-- | service/http/service.go | 8 | ||||
-rw-r--r-- | service/rpc/service_test.go | 11 |
3 files changed, 16 insertions, 7 deletions
diff --git a/service/http/rpc.go b/service/http/rpc.go index 3390a93d..7b38dece 100644 --- a/service/http/rpc.go +++ b/service/http/rpc.go @@ -20,7 +20,7 @@ func (rpc *rpcServer) Reset(reset bool, r *string) error { } *r = "OK" - return rpc.svc.rr.Reset() + return rpc.svc.Server().Reset() } // Workers returns list of active workers and their stats. @@ -29,6 +29,6 @@ func (rpc *rpcServer) Workers(list bool, r *WorkerList) (err error) { return errors.New("http server is not running") } - r.Workers, err = util.ServerState(rpc.svc.rr) + r.Workers, err = util.ServerState(rpc.svc.Server()) return err } diff --git a/service/http/service.go b/service/http/service.go index 1a06a76a..47175ec3 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -118,6 +118,14 @@ func (s *Service) Stop() { go s.http.Shutdown(context.Background()) } +// Server returns associated roadrunner server (if any). +func (s *Service) Server() *roadrunner.Server { + s.mu.Lock() + defer s.mu.Unlock() + + return s.rr +} + // ServeHTTP handles connection using set of middleware and rr PSR-7 server. func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) { if s.https != nil && r.TLS == nil && s.cfg.SSL.Redirect { diff --git a/service/rpc/service_test.go b/service/rpc/service_test.go index 0278d287..41233070 100644 --- a/service/rpc/service_test.go +++ b/service/rpc/service_test.go @@ -1,6 +1,7 @@ package rpc import ( + "github.com/spiral/roadrunner/service" "github.com/spiral/roadrunner/service/env" "github.com/stretchr/testify/assert" "testing" @@ -31,7 +32,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"}, service.NewContainer(nil), nil) assert.NoError(t, err) assert.True(t, ok) @@ -39,7 +40,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"}, service.NewContainer(nil), nil) assert.NoError(t, err) assert.True(t, ok) @@ -48,7 +49,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"}, service.NewContainer(nil), nil) assert.NoError(t, err) assert.True(t, ok) @@ -61,7 +62,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"}, service.NewContainer(nil), nil) assert.NoError(t, err) assert.True(t, ok) @@ -85,7 +86,7 @@ func Test_Serve_Client(t *testing.T) { func TestSetEnv(t *testing.T) { s := &Service{} e := env.NewService(map[string]string{}) - ok, err := s.Init(&Config{Enable: true, Listen: "tcp://localhost:9018"}, e) + ok, err := s.Init(&Config{Enable: true, Listen: "tcp://localhost:9018"}, service.NewContainer(nil), e) assert.NoError(t, err) assert.True(t, ok) |