summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-03 13:12:59 +0300
committerWolfy-J <[email protected]>2018-06-03 13:12:59 +0300
commita891f511f973c102f3a425a0686203fba2117841 (patch)
tree78f4534e6235b34b963799b0fbda202f91faca14 /http
parent6f805059d5eff80ad89ed8b2abc50bdd52fb3e4b (diff)
minor CS
Diffstat (limited to 'http')
-rw-r--r--http/rpc.go37
-rw-r--r--http/server.go2
2 files changed, 6 insertions, 33 deletions
diff --git a/http/rpc.go b/http/rpc.go
index c065432c..94aeca23 100644
--- a/http/rpc.go
+++ b/http/rpc.go
@@ -2,34 +2,17 @@ package http
import (
"github.com/sirupsen/logrus"
+ "github.com/spiral/roadrunner/utils"
)
type rpcServer struct {
- Service *Service
+ service *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.
- NumExecs uint64 `json:"numExecs"`
-
- // Created is unix nano timestamp of worker creation time.
- Created int64 `json:"created"`
-
- // Updated is unix nano timestamp of last worker execution.
- Updated int64 `json:"updated"`
+ Workers []utils.Worker `json:"workers"`
}
// Reset resets underlying RR worker pool and restarts all of it's workers.
@@ -37,21 +20,11 @@ func (rpc *rpcServer) Reset(reset bool, r *string) error {
logrus.Info("resetting worker pool")
*r = "OK"
- return rpc.Service.srv.rr.Reset()
+ return rpc.service.srv.rr.Reset()
}
// Workers returns list of active workers and their stats.
func (rpc *rpcServer) Workers(list bool, r *WorkerList) error {
- for _, w := range rpc.Service.srv.rr.Workers() {
- state := w.State()
- r.Workers = append(r.Workers, Worker{
- Pid: *w.Pid,
- Status: state.String(),
- NumExecs: state.NumExecs(),
- Created: w.Created.UnixNano(),
- Updated: state.Updated().UnixNano(),
- })
- }
-
+ r.Workers = utils.FetchWorkers(rpc.service.srv.rr)
return nil
}
diff --git a/http/server.go b/http/server.go
index 41e39133..22c6380a 100644
--- a/http/server.go
+++ b/http/server.go
@@ -8,7 +8,7 @@ import (
"strconv"
)
-// Service serves http connections to underlying PHP application using PSR-7 protocol. Context will include request headers,
+// service serves http connections to underlying PHP application using PSR-7 protocol. Context will include request headers,
// parsed files and query, payload will include parsed form dataTree (if any).
type Server struct {
cfg *Config