-
Notifications
You must be signed in to change notification settings - Fork 29
/
health.go
30 lines (23 loc) · 1.08 KB
/
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
package service
/* See for references:
- https://cloud.google.com/blog/topics/developers-practitioners/health-checking-your-grpc-servers-gke
- https://grpc-ecosystem.github.io/grpc-gateway/docs/operations/health_check/
- https://github.com/grpc/grpc/blob/master/doc/health-checking.md */
import (
"log"
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
healthpb "google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/status"
)
// HealthService is the server API for the gRPC health service
type HealthService struct{}
// Check performs a health of the gRPC service
func (hs *HealthService) Check(ctx context.Context, in *healthpb.HealthCheckRequest) (*healthpb.HealthCheckResponse, error) {
log.Printf("[HealthService] Check()")
return &healthpb.HealthCheckResponse{Status: healthpb.HealthCheckResponse_SERVING}, nil
}
// Watch is for streaming health-check (not yet implemented)
func (hs *HealthService) Watch(in *healthpb.HealthCheckRequest, srv healthpb.Health_WatchServer) error {
return status.Error(codes.Unimplemented, "Watch is not implemented")
}