github.com/pachyderm/pachyderm@v1.13.4/src/server/health/health.go (about) 1 package health 2 3 import ( 4 "github.com/gogo/protobuf/types" 5 "github.com/pachyderm/pachyderm/src/client/health" 6 "github.com/pachyderm/pachyderm/src/client/pkg/errors" 7 "golang.org/x/net/context" 8 ) 9 10 // Server adds the Ready method to health.HealthServer. 11 type Server interface { 12 health.HealthServer 13 Ready() 14 } 15 16 // NewHealthServer returns a new health server 17 func NewHealthServer() Server { 18 return &healthServer{} 19 } 20 21 type healthServer struct { 22 ready bool 23 } 24 25 // Health implements the Health method for healthServer. 26 func (h *healthServer) Health(context.Context, *types.Empty) (*types.Empty, error) { 27 if !h.ready { 28 return nil, errors.Errorf("server not ready") 29 } 30 return &types.Empty{}, nil 31 } 32 33 // Ready tells pachd to start responding positively to Health requests. This 34 // will cause the node to pass its k8s readiness check. 35 func (h *healthServer) Ready() { 36 h.ready = true 37 }