Browse Source

grpcproxy: return interface

Xiang Li 9 years ago
parent
commit
5271cf0160
4 changed files with 5 additions and 9 deletions
  1. 1 5
      proxy/grpcproxy/kv.go
  2. 2 2
      proxy/grpcproxy/kv_test.go
  3. 1 1
      proxy/grpcproxy/lease.go
  4. 1 1
      proxy/grpcproxy/watch.go

+ 1 - 5
proxy/grpcproxy/kv.go

@@ -27,7 +27,7 @@ type kvProxy struct {
 	cache  cache.Cache
 	cache  cache.Cache
 }
 }
 
 
-func NewKvProxy(c *clientv3.Client) *kvProxy {
+func NewKvProxy(c *clientv3.Client) pb.KVServer {
 	return &kvProxy{
 	return &kvProxy{
 		client: c,
 		client: c,
 		cache:  cache.NewCache(cache.DefaultMaxEntries),
 		cache:  cache.NewCache(cache.DefaultMaxEntries),
@@ -102,10 +102,6 @@ func (p *kvProxy) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.Com
 	return (*pb.CompactionResponse)(resp), err
 	return (*pb.CompactionResponse)(resp), err
 }
 }
 
 
-func (p *kvProxy) Close() error {
-	return p.client.Close()
-}
-
 func requestOpToOp(union *pb.RequestOp) clientv3.Op {
 func requestOpToOp(union *pb.RequestOp) clientv3.Op {
 	switch tv := union.Request.(type) {
 	switch tv := union.Request.(type) {
 	case *pb.RequestOp_RequestRange:
 	case *pb.RequestOp_RequestRange:

+ 2 - 2
proxy/grpcproxy/kv_test.go

@@ -50,10 +50,11 @@ func TestKVProxyRange(t *testing.T) {
 	if err != nil {
 	if err != nil {
 		t.Fatalf("err = %v, want nil", err)
 		t.Fatalf("err = %v, want nil", err)
 	}
 	}
+	client.Close()
 }
 }
 
 
 type kvproxyTestServer struct {
 type kvproxyTestServer struct {
-	kp     *kvProxy
+	kp     pb.KVServer
 	server *grpc.Server
 	server *grpc.Server
 	l      net.Listener
 	l      net.Listener
 }
 }
@@ -61,7 +62,6 @@ type kvproxyTestServer struct {
 func (kts *kvproxyTestServer) close() {
 func (kts *kvproxyTestServer) close() {
 	kts.server.Stop()
 	kts.server.Stop()
 	kts.l.Close()
 	kts.l.Close()
-	kts.kp.Close()
 }
 }
 
 
 func newKVProxyServer(endpoints []string, t *testing.T) *kvproxyTestServer {
 func newKVProxyServer(endpoints []string, t *testing.T) *kvproxyTestServer {

+ 1 - 1
proxy/grpcproxy/lease.go

@@ -25,7 +25,7 @@ type leaseProxy struct {
 	client *clientv3.Client
 	client *clientv3.Client
 }
 }
 
 
-func NewLeaseProxy(c *clientv3.Client) *leaseProxy {
+func NewLeaseProxy(c *clientv3.Client) pb.LeaseServer {
 	return &leaseProxy{
 	return &leaseProxy{
 		client: c,
 		client: c,
 	}
 	}

+ 1 - 1
proxy/grpcproxy/watch.go

@@ -32,7 +32,7 @@ type watchProxy struct {
 	nextStreamID int64
 	nextStreamID int64
 }
 }
 
 
-func NewWatchProxy(c *clientv3.Client) *watchProxy {
+func NewWatchProxy(c *clientv3.Client) pb.WatchServer {
 	return &watchProxy{
 	return &watchProxy{
 		c: c,
 		c: c,
 		wgs: watchergroups{
 		wgs: watchergroups{