From 5d669290e360f76505eb027e8f379d0371262fe2 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Thu, 10 Aug 2017 22:26:46 -0700 Subject: [PATCH] embed: support experimental v2v3 proxy option --- embed/config.go | 1 + embed/etcd.go | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/embed/config.go b/embed/config.go index 9f1516b65..8d429cb0a 100644 --- a/embed/config.go +++ b/embed/config.go @@ -145,6 +145,7 @@ type Config struct { // Experimental flags ExperimentalCorruptCheckTime time.Duration `json:"experimental-corrupt-check-time"` + ExperimentalEnableV2V3 string `json:"experimental-enable-v2v3"` } // configYAML holds the config suitable for yaml parsing diff --git a/embed/etcd.go b/embed/etcd.go index 5959f4059..6ceb55b79 100644 --- a/embed/etcd.go +++ b/embed/etcd.go @@ -29,6 +29,8 @@ import ( "github.com/coreos/etcd/etcdserver" "github.com/coreos/etcd/etcdserver/api/etcdhttp" "github.com/coreos/etcd/etcdserver/api/v2http" + "github.com/coreos/etcd/etcdserver/api/v2v3" + "github.com/coreos/etcd/etcdserver/api/v3client" "github.com/coreos/etcd/etcdserver/api/v3rpc" "github.com/coreos/etcd/pkg/cors" "github.com/coreos/etcd/pkg/debugutil" @@ -409,7 +411,12 @@ func (e *Etcd) serve() (err error) { // Start a client server goroutine for each listen address var h http.Handler if e.Config().EnableV2 { - h = v2http.NewClientHandler(e.Server, e.Server.Cfg.ReqTimeout()) + if len(e.Config().ExperimentalEnableV2V3) > 0 { + srv := v2v3.NewServer(v3client.New(e.Server), e.cfg.ExperimentalEnableV2V3) + h = v2http.NewClientHandler(srv, e.Server.Cfg.ReqTimeout()) + } else { + h = v2http.NewClientHandler(e.Server, e.Server.Cfg.ReqTimeout()) + } } else { mux := http.NewServeMux() etcdhttp.HandleBasic(mux, e.Server)