Health check
With the gRPC Health Checking Protocol
To use the gRPC health checking protocol you must add the two health checking methods, Watch
and Check
.
Registering the health server
- Add
google.golang.org/grpc/health/grpc_health_v1
to your imports - Register the health server with
grpc_health_v1.RegisterHealthServer(grpcServer, yourService)
Adding the health check methods
- Check method
func (s *serviceServer) Check(ctx context.Context, in *health.HealthCheckRequest) (*health.HealthCheckResponse, error) {
return &health.HealthCheckResponse{Status: health.HealthCheckResponse_SERVING}, nil
}
- Watch method
func (s *serviceServer) Watch(in *health.HealthCheckRequest, _ health.Health_WatchServer) error {
// Example of how to register both methods but only implement the Check method.
return status.Error(codes.Unimplemented, "unimplemented")
}
- You can test the functionality with GRPC health probe.