-
Notifications
You must be signed in to change notification settings - Fork 23
/
server.go
35 lines (29 loc) · 940 Bytes
/
server.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
package etcdserver
import (
"github.com/k3s-io/kine/pkg/server"
"go.etcd.io/etcd/api/v3/etcdserverpb"
"google.golang.org/grpc"
"google.golang.org/grpc/health"
healthpb "google.golang.org/grpc/health/grpc_health_v1"
)
type EtcdServer struct {
*server.KVServerBridge
backend server.Backend
}
func NewEtcdServer(backend server.Backend) *EtcdServer {
return &EtcdServer{
KVServerBridge: server.New(backend, ""),
backend: backend,
}
}
func (svr *EtcdServer) Register(server *grpc.Server) {
etcdserverpb.RegisterWatchServer(server, svr)
etcdserverpb.RegisterKVServer(server, svr)
// Bridge comes from the implementation of kine
etcdserverpb.RegisterLeaseServer(server, svr)
etcdserverpb.RegisterClusterServer(server, svr)
etcdserverpb.RegisterMaintenanceServer(server, svr)
hsrv := health.NewServer()
hsrv.SetServingStatus("", healthpb.HealthCheckResponse_SERVING)
healthpb.RegisterHealthServer(server, hsrv)
}