summaryrefslogtreecommitdiff
path: root/_____/http/rpc.go
diff options
context:
space:
mode:
Diffstat (limited to '_____/http/rpc.go')
-rw-r--r--_____/http/rpc.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/_____/http/rpc.go b/_____/http/rpc.go
index e54eae7c..673ff2bb 100644
--- a/_____/http/rpc.go
+++ b/_____/http/rpc.go
@@ -42,3 +42,37 @@ func (rpc *rpcServer) Workers(list bool, r *WorkerList) error {
r.Workers = utils.FetchWorkers(rpc.service.srv.rr)
return nil
}
+
+// 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"`
+}
+
+// FetchWorkers fetches list of workers from RR Server.
+func FetchWorkers(srv *roadrunner.Server) (result []Worker) {
+ for _, w := range srv.Workers() {
+ state := w.State()
+ result = append(result, Worker{
+ Pid: *w.Pid,
+ Status: state.String(),
+ NumExecs: state.NumExecs(),
+ Created: w.Created.UnixNano(),
+ Updated: state.Updated().UnixNano(),
+ })
+ }
+
+ return
+} \ No newline at end of file