diff options
author | Wolfy-J <[email protected]> | 2018-06-03 13:12:59 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-03 13:12:59 +0300 |
commit | a891f511f973c102f3a425a0686203fba2117841 (patch) | |
tree | 78f4534e6235b34b963799b0fbda202f91faca14 /utils | |
parent | 6f805059d5eff80ad89ed8b2abc50bdd52fb3e4b (diff) |
minor CS
Diffstat (limited to 'utils')
-rw-r--r-- | utils/workers.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/utils/workers.go b/utils/workers.go new file mode 100644 index 00000000..0c4f778f --- /dev/null +++ b/utils/workers.go @@ -0,0 +1,37 @@ +package utils + +import "github.com/spiral/roadrunner" + +// 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 +} |