浏览代码

adapter, integration: split out grpc adapters from grpcproxy package

Break cyclic dependency:
clientv3/naming <-> integration <-> v3client <-> grpcproxy <-> clientv3/naming
Anthony Romano 8 年之前
父节点
当前提交
b025cdd097

+ 4 - 3
integration/cluster_proxy.go

@@ -22,6 +22,7 @@ import (
 	"github.com/coreos/etcd/clientv3"
 	pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
 	"github.com/coreos/etcd/proxy/grpcproxy"
+	"github.com/coreos/etcd/proxy/grpcproxy/adapter"
 )
 
 var (
@@ -48,9 +49,9 @@ func toGRPC(c *clientv3.Client) grpcAPI {
 	lp, lpch := grpcproxy.NewLeaseProxy(c)
 	grpc := grpcAPI{
 		pb.NewClusterClient(c.ActiveConnection()),
-		grpcproxy.KvServerToKvClient(kvp),
-		grpcproxy.LeaseServerToLeaseClient(lp),
-		grpcproxy.WatchServerToWatchClient(wp),
+		adapter.KvServerToKvClient(kvp),
+		adapter.LeaseServerToLeaseClient(lp),
+		adapter.WatchServerToWatchClient(wp),
 		pb.NewMaintenanceClient(c.ActiveConnection()),
 		pb.NewAuthClient(c.ActiveConnection()),
 	}

+ 1 - 1
proxy/grpcproxy/chan_stream.go → proxy/grpcproxy/adapter/chan_stream.go

@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package grpcproxy
+package adapter
 
 import (
 	"golang.org/x/net/context"

+ 17 - 0
proxy/grpcproxy/adapter/doc.go

@@ -0,0 +1,17 @@
+// Copyright 2017 The etcd Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Package adapter provides gRPC adapters between client and server
+// gRPC interfaces without needing to go through a gRPC connection.
+package adapter

+ 1 - 1
proxy/grpcproxy/kv_client_adapter.go → proxy/grpcproxy/adapter/kv_client_adapter.go

@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package grpcproxy
+package adapter
 
 import (
 	pb "github.com/coreos/etcd/etcdserver/etcdserverpb"

+ 1 - 1
proxy/grpcproxy/lease_client_adapter.go → proxy/grpcproxy/adapter/lease_client_adapter.go

@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package grpcproxy
+package adapter
 
 import (
 	"golang.org/x/net/context"

+ 2 - 2
proxy/grpcproxy/watch_client_adapter.go → proxy/grpcproxy/adapter/watch_client_adapter.go

@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-package grpcproxy
+package adapter
 
 import (
 	"errors"
@@ -23,7 +23,7 @@ import (
 	"google.golang.org/grpc/metadata"
 )
 
-var errAlreadySentHeader = errors.New("grpcproxy: already send header")
+var errAlreadySentHeader = errors.New("adapter: already sent header")
 
 type ws2wc struct{ wserv pb.WatchServer }