summaryrefslogtreecommitdiff
path: root/plugins/status/rpc.go
blob: 755a06fa8158481eaa0e97fec6d5639541efaab3 (plain)
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
package status

import (
	"github.com/spiral/errors"
	"github.com/spiral/roadrunner/v2/plugins/logger"
)

type rpc struct {
	srv *Plugin
	log logger.Logger
}

// Status return current status of the provided plugin
func (rpc *rpc) Status(service string, status *Status) error {
	const op = errors.Op("checker_rpc_status")
	rpc.log.Debug("started Status method", "service", service)
	st, err := rpc.srv.status(service)
	if err != nil {
		return errors.E(op, err)
	}

	*status = st

	rpc.log.Debug("status code", "code", st.Code)
	rpc.log.Debug("successfully finished the Status method")
	return nil
}

// Status return current status of the provided plugin
func (rpc *rpc) Ready(service string, status *Status) error {
	const op = errors.Op("checker_rpc_ready")
	rpc.log.Debug("started Ready method", "service", service)
	st, err := rpc.srv.ready(service)
	if err != nil {
		return errors.E(op, err)
	}

	*status = st

	rpc.log.Debug("status code", "code", st.Code)
	rpc.log.Debug("successfully finished the Ready method")
	return nil
}