-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrpc.go
50 lines (42 loc) · 1.3 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package status
import (
statusV1 "github.com/roadrunner-server/api/v4/build/status/v1"
"github.com/roadrunner-server/errors"
"go.uber.org/zap"
)
type rpc struct {
srv *Plugin
log *zap.Logger
}
// Status returns the current status of the provided plugin
func (rpc *rpc) Status(req *statusV1.Request, resp *statusV1.Response) error {
const op = errors.Op("checker_rpc_status")
rpc.log.Debug("Status method was invoked", zap.String("plugin", req.GetPlugin()))
st, err := rpc.srv.status(req.GetPlugin())
if err != nil {
resp.Message = err.Error()
return errors.E(op, err)
}
if st != nil {
resp.Code = int64(st.Code)
rpc.log.Debug("status code", zap.Int("code", st.Code))
}
rpc.log.Debug("successfully finished the Status method")
return nil
}
// Ready to return the readiness check of the provided plugin
func (rpc *rpc) Ready(req *statusV1.Request, resp *statusV1.Response) error {
const op = errors.Op("checker_rpc_ready")
rpc.log.Debug("Ready method was invoked", zap.String("plugin", req.GetPlugin()))
st, err := rpc.srv.ready(req.GetPlugin())
if err != nil {
resp.Message = err.Error()
return errors.E(op, err)
}
if st != nil {
resp.Code = int64(st.Code)
rpc.log.Debug("status code", zap.Int("code", st.Code))
}
rpc.log.Debug("successfully finished the Ready method")
return nil
}