-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrpc.go
More file actions
50 lines (42 loc) · 1.32 KB
/
rpc.go
File metadata and controls
50 lines (42 loc) · 1.32 KB
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 (
statusV2 "github.com/roadrunner-server/api-go/v6/status/v2"
"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 *statusV2.StatusRequest, resp *statusV2.StatusResponse) 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 *statusV2.StatusRequest, resp *statusV2.StatusResponse) 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
}