-
Notifications
You must be signed in to change notification settings - Fork 669
/
service.go
42 lines (34 loc) · 1.15 KB
/
service.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
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package health
import (
"net/http"
"github.com/ava-labs/avalanchego/utils/logging"
)
type Service struct {
log logging.Logger
health Reporter
}
// APIReply is the response for Readiness, Health, and Liveness.
type APIReply struct {
Checks map[string]Result `json:"checks"`
Healthy bool `json:"healthy"`
}
// Readiness returns if the node has finished initialization
func (s *Service) Readiness(_ *http.Request, _ *struct{}, reply *APIReply) error {
s.log.Debug("Health.readiness called")
reply.Checks, reply.Healthy = s.health.Readiness()
return nil
}
// Health returns a summation of the health of the node
func (s *Service) Health(_ *http.Request, _ *struct{}, reply *APIReply) error {
s.log.Debug("Health.health called")
reply.Checks, reply.Healthy = s.health.Health()
return nil
}
// Liveness returns if the node is in need of a restart
func (s *Service) Liveness(_ *http.Request, _ *struct{}, reply *APIReply) error {
s.log.Debug("Health.liveness called")
reply.Checks, reply.Healthy = s.health.Liveness()
return nil
}