minor fix including removal of debugging logs, error code fix, etc.

This commit is contained in:
iamqizhao
2016-06-27 15:30:20 -07:00
parent 3e71fb360d
commit 01ef81a4d9
5 changed files with 10 additions and 13 deletions

View File

@ -298,7 +298,6 @@ func (rr *roundRobin) Get(ctx context.Context, opts BalancerGetOptions) (addr Ad
}
}
}
// There is no address available.
if !opts.BlockingWait {
if len(rr.addrs) == 0 {
rr.mu.Unlock()

View File

@ -35,7 +35,6 @@ package grpc
import (
"bytes"
//"fmt"
"io"
"time"
@ -170,8 +169,6 @@ func Invoke(ctx context.Context, method string, args, reply interface{}, cc *Cli
}
// ALl the other errors are treated as Internal errors.
return Errorf(codes.Internal, "%v", err)
// All the remaining cases are treated as fatal.
//panic(fmt.Sprintf("ClientConn.getTransport got an unsupported error: %v", err))
}
if c.traceInfo.tr != nil {
c.traceInfo.tr.LazyLog(&payload{sent: true, msg: args}, true)

View File

@ -664,7 +664,7 @@ func (ac *addrConn) wait(ctx context.Context, failFast bool) (transport.ClientTr
default:
if ac.state == TransientFailure && failFast {
ac.mu.Unlock()
return nil, transport.StreamErrorf(codes.Canceled, "grpc: RPC failed fast due to transport failure")
return nil, transport.StreamErrorf(codes.Unavailable, "grpc: RPC failed fast due to transport failure")
}
ready := ac.ready
if ready == nil {
@ -680,7 +680,7 @@ func (ac *addrConn) wait(ctx context.Context, failFast bool) (transport.ClientTr
ac.mu.Lock()
if ac.state == TransientFailure && failFast {
ac.mu.Unlock()
return nil, transport.StreamErrorf(codes.Canceled, "grpc: RPC failed fast due to transport failure")
return nil, transport.StreamErrorf(codes.Unavailable, "grpc: RPC failed fast due to transport failure")
}
ac.mu.Unlock()

View File

@ -183,9 +183,10 @@ func Trailer(md *metadata.MD) CallOption {
// FailFast configures the action to take when an RPC is attempted on broken
// connections or unreachable servers. If failfast is true, the RPC will fail
// immediately. Otherwise, the RPC client will block the call until a
// immediately. Otherwise, the RPC client will block the call until a
// connection is available (or the call is canceled or times out) and will retry
// the call if it fails due to a transient error.
// the call if it fails due to a transient error. Please refer to
// https://github.com/grpc/grpc/blob/master/doc/fail_fast.md
func FailFast(failFast bool) CallOption {
return beforeCall(func(c *callInfo) error {
c.failFast = failFast

View File

@ -595,12 +595,12 @@ func testFailFast(t *testing.T, e env) {
if _, err := tc.EmptyCall(ctx, &testpb.Empty{}, grpc.FailFast(false)); grpc.Code(err) != codes.DeadlineExceeded {
t.Fatalf("TestService/EmptyCall(%v, _) = _, %v, want _, error code: %d", ctx, err, codes.DeadlineExceeded)
}
// The client keeps reconnecting and ongoing fail-fast RPCs should fail with code.Canceled.
if _, err := tc.EmptyCall(context.Background(), &testpb.Empty{}); grpc.Code(err) != codes.Canceled {
t.Fatalf("TestService/EmptyCall(_, _, _) = _, %v, want _, error code: %d", err, codes.Canceled)
// The client keeps reconnecting and ongoing fail-fast RPCs should fail with code.Unavailable.
if _, err := tc.EmptyCall(context.Background(), &testpb.Empty{}); grpc.Code(err) != codes.Unavailable {
t.Fatalf("TestService/EmptyCall(_, _, _) = _, %v, want _, error code: %d", err, codes.Unavailable)
}
if _, err := tc.StreamingInputCall(ctx); grpc.Code(err) != codes.Canceled {
t.Fatalf("TestService/StreamingInputCall(_) = _, %v, want _, error code: %d", err, codes.Canceled)
if _, err := tc.StreamingInputCall(ctx); grpc.Code(err) != codes.Unavailable {
t.Fatalf("TestService/StreamingInputCall(_) = _, %v, want _, error code: %d", err, codes.Unavailable)
}
awaitNewConnLogOutput()