Browse Source

etcdmain: support key leasing in grpcproxy

visheshnp 8 years ago
parent
commit
9be715bb66
1 changed files with 7 additions and 1 deletions
  1. 7 1
      etcdmain/grpc_proxy.go

+ 7 - 1
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 != "" {