forked from pachyderm/pachyderm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
health.go
38 lines (31 loc) · 831 Bytes
/
health.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
package health
import (
"fmt"
"github.com/gogo/protobuf/types"
"github.com/pachyderm/pachyderm/src/client/health"
"golang.org/x/net/context"
)
// Server adds the Ready method to health.HealthServer.
type Server interface {
health.HealthServer
Ready()
}
// NewHealthServer returns a new health server
func NewHealthServer() Server {
return &healthServer{}
}
type healthServer struct {
ready bool
}
// Health implements the Health method for healthServer.
func (h *healthServer) Health(context.Context, *types.Empty) (*types.Empty, error) {
if !h.ready {
return nil, fmt.Errorf("server not ready")
}
return &types.Empty{}, nil
}
// Ready tells pachd to start responding positively to Health requests. This
// will cause the node to pass its k8s readiness check.
func (h *healthServer) Ready() {
h.ready = true
}