forked from spiral-modules/php-grpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpc.go
36 lines (29 loc) · 816 Bytes
/
rpc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package grpc
import (
"errors"
"github.com/spiral/roadrunner/util"
)
type rpcServer struct {
svc *Service
}
// WorkerList contains list of workers.
type WorkerList struct {
// Workers is list of workers.
Workers []*util.State `json:"workers"`
}
// Reset resets underlying RR worker pool and restarts all of it's workers.
func (rpc *rpcServer) Reset(reset bool, r *string) error {
if rpc.svc == nil || rpc.svc.grpc == nil {
return errors.New("grpc server is not running")
}
*r = "OK"
return rpc.svc.rr.Reset()
}
// Workers returns list of active workers and their stats.
func (rpc *rpcServer) Workers(list bool, r *WorkerList) (err error) {
if rpc.svc == nil || rpc.svc.grpc == nil {
return errors.New("grpc server is not running")
}
r.Workers, err = util.ServerState(rpc.svc.rr)
return err
}