Browse Source

etcdserver/api/v3rpc: add default grpc health service

Gyu-Ho Lee 8 years ago
parent
commit
c1e3172e3a
1 changed files with 10 additions and 0 deletions
  1. 10 0
      etcdserver/api/v3rpc/grpc.go

+ 10 - 0
etcdserver/api/v3rpc/grpc.go

@@ -19,9 +19,12 @@ import (
 
 	"github.com/coreos/etcd/etcdserver"
 	pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
+
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/credentials"
 	"google.golang.org/grpc/grpclog"
+	"google.golang.org/grpc/health"
+	healthpb "google.golang.org/grpc/health/grpc_health_v1"
 )
 
 const grpcOverheadBytes = 512 * 1024
@@ -48,5 +51,12 @@ func Server(s *etcdserver.EtcdServer, tls *tls.Config) *grpc.Server {
 	pb.RegisterAuthServer(grpcServer, NewAuthServer(s))
 	pb.RegisterMaintenanceServer(grpcServer, NewMaintenanceServer(s))
 
+	// server should register all the services manually
+	// use empty service name for all etcd services' health status,
+	// see https://github.com/grpc/grpc/blob/master/doc/health-checking.md for more
+	hsrv := health.NewServer()
+	hsrv.SetServingStatus("", healthpb.HealthCheckResponse_SERVING)
+	healthpb.RegisterHealthServer(grpcServer, hsrv)
+
 	return grpcServer
 }