From 9be715bb66fb8afa8ecb81292448374739ca5090 Mon Sep 17 00:00:00 2001 From: visheshnp Date: Wed, 28 Jun 2017 15:09:44 -0700 Subject: [PATCH] etcdmain: support key leasing in grpcproxy --- etcdmain/grpc_proxy.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/etcdmain/grpc_proxy.go b/etcdmain/grpc_proxy.go index 969dd83ed..2e4adc45e 100644 --- a/etcdmain/grpc_proxy.go +++ b/etcdmain/grpc_proxy.go @@ -26,6 +26,7 @@ import ( "time" "github.com/coreos/etcd/clientv3" + "github.com/coreos/etcd/clientv3/leasing" "github.com/coreos/etcd/clientv3/namespace" "github.com/coreos/etcd/clientv3/ordering" "github.com/coreos/etcd/etcdserver/api/etcdhttp" @@ -70,6 +71,7 @@ var ( grpcProxyResolverTTL int grpcProxyNamespace string + grpcProxyLeasing string grpcProxyEnablePprof bool grpcProxyEnableOrdering bool @@ -124,7 +126,7 @@ func newGRPCProxyStartCommand() *cobra.Command { // experimental flags cmd.Flags().BoolVar(&grpcProxyEnableOrdering, "experimental-serializable-ordering", false, "Ensure serializable reads have monotonically increasing store revisions across endpoints.") - + cmd.Flags().StringVar(&grpcProxyLeasing, "experimental-leasing-prefix", "", "leasing metadata prefix for disconnected linearized reads.") return &cmd } @@ -282,6 +284,10 @@ func newGRPCProxyServer(client *clientv3.Client) *grpc.Server { client.Lease = namespace.NewLease(client.Lease, grpcProxyNamespace) } + if len(grpcProxyLeasing) > 0 { + client.KV, _ = leasing.NewKV(client, grpcProxyLeasing) + } + kvp, _ := grpcproxy.NewKvProxy(client) watchp, _ := grpcproxy.NewWatchProxy(client) if grpcProxyResolverPrefix != "" {