proxy/grpcproxy: deprecate "grpc.ErrClientConnClosing"

Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
This commit is contained in:
Gyuho Lee 2019-08-05 00:06:59 -07:00
parent faa1d9d206
commit 5d19b96341
3 changed files with 10 additions and 5 deletions

View File

@ -18,7 +18,9 @@ import (
"context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)
// chanServerStream implements grpc.ServerStream with a chanStream
@ -120,7 +122,7 @@ func (s *chanStream) RecvMsg(m interface{}) error {
select {
case msg, ok := <-s.recvc:
if !ok {
return grpc.ErrClientConnClosing
return status.Error(codes.Canceled, "the client connection is closing")
}
if err, ok := msg.(error); ok {
return err

View File

@ -26,7 +26,9 @@ import (
pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)
type leaseProxy struct {
@ -214,7 +216,7 @@ func (lp *leaseProxy) LeaseKeepAlive(stream pb.Lease_LeaseKeepAliveServer) error
case <-lostLeaderC:
return rpctypes.ErrNoLeader
case <-lp.leader.disconnectNotify():
return grpc.ErrClientConnClosing
return status.Error(codes.Canceled, "the client connection is closing")
default:
if err != nil {
return err

View File

@ -23,8 +23,9 @@ import (
"go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)
type watchProxy struct {
@ -80,7 +81,7 @@ func (wp *watchProxy) Watch(stream pb.Watch_WatchServer) (err error) {
wp.mu.Unlock()
select {
case <-wp.leader.disconnectNotify():
return grpc.ErrClientConnClosing
return status.Error(codes.Canceled, "the client connection is closing")
default:
return wp.ctx.Err()
}
@ -153,7 +154,7 @@ func (wp *watchProxy) Watch(stream pb.Watch_WatchServer) (err error) {
case <-lostLeaderC:
return rpctypes.ErrNoLeader
case <-wp.leader.disconnectNotify():
return grpc.ErrClientConnClosing
return status.Error(codes.Canceled, "the client connection is closing")
default:
return wps.ctx.Err()
}