diff options
author | Wolfy-J <[email protected]> | 2018-09-29 23:17:20 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-09-29 23:17:20 +0300 |
commit | c3ca96f4c9057755de78f0484dd3cad35f32c34f (patch) | |
tree | bc53ec9b727d5077dc9b8fa73a7cf9072760ea16 /service/http | |
parent | 84d6405ddc232b83bf89594f98b7fcc78a2e8573 (diff) | |
parent | 0556629eec5634a7586cc8da56b47e823011ca2c (diff) |
Merge branch 'feature/1.2.3' into feature/1.3.0
Diffstat (limited to 'service/http')
-rw-r--r-- | service/http/rpc.go | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/service/http/rpc.go b/service/http/rpc.go index 9dfe718e..08b3f262 100644 --- a/service/http/rpc.go +++ b/service/http/rpc.go @@ -2,6 +2,7 @@ package http import ( "github.com/pkg/errors" + "github.com/spiral/roadrunner/util" ) type rpcServer struct{ svc *Service } @@ -9,22 +10,7 @@ type rpcServer struct{ svc *Service } // WorkerList contains list of workers. type WorkerList struct { // Workers is list of workers. - Workers []Worker `json:"workers"` -} - -// Worker provides information about specific worker. -type Worker struct { - // Pid contains process id. - Pid int `json:"pid"` - - // Status of the worker. - Status string `json:"status"` - - // Number of worker executions. - NumJobs int64 `json:"numExecs"` - - // Created is unix nano timestamp of worker creation time. - Created int64 `json:"created"` + Workers []*util.State `json:"workers"` } // Reset resets underlying RR worker pool and restarts all of it's workers. @@ -38,20 +24,11 @@ func (rpc *rpcServer) Reset(reset bool, r *string) error { } // Workers returns list of active workers and their stats. -func (rpc *rpcServer) Workers(list bool, r *WorkerList) error { +func (rpc *rpcServer) Workers(list bool, r *WorkerList) (err error) { if rpc.svc == nil || rpc.svc.srv == nil { return errors.New("http server is not running") } - for _, w := range rpc.svc.rr.Workers() { - state := w.State() - r.Workers = append(r.Workers, Worker{ - Pid: *w.Pid, - Status: state.String(), - NumJobs: state.NumExecs(), - Created: w.Created.UnixNano(), - }) - } - - return nil + r.Workers, err = util.ServerState(rpc.svc.rr) + return err } |