minor fix including removal of debugging logs, error code fix, etc.
This commit is contained in:
@ -298,7 +298,6 @@ func (rr *roundRobin) Get(ctx context.Context, opts BalancerGetOptions) (addr Ad
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// There is no address available.
|
|
||||||
if !opts.BlockingWait {
|
if !opts.BlockingWait {
|
||||||
if len(rr.addrs) == 0 {
|
if len(rr.addrs) == 0 {
|
||||||
rr.mu.Unlock()
|
rr.mu.Unlock()
|
||||||
|
3
call.go
3
call.go
@ -35,7 +35,6 @@ package grpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
//"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"time"
|
"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.
|
// ALl the other errors are treated as Internal errors.
|
||||||
return Errorf(codes.Internal, "%v", err)
|
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 {
|
if c.traceInfo.tr != nil {
|
||||||
c.traceInfo.tr.LazyLog(&payload{sent: true, msg: args}, true)
|
c.traceInfo.tr.LazyLog(&payload{sent: true, msg: args}, true)
|
||||||
|
@ -664,7 +664,7 @@ func (ac *addrConn) wait(ctx context.Context, failFast bool) (transport.ClientTr
|
|||||||
default:
|
default:
|
||||||
if ac.state == TransientFailure && failFast {
|
if ac.state == TransientFailure && failFast {
|
||||||
ac.mu.Unlock()
|
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
|
ready := ac.ready
|
||||||
if ready == nil {
|
if ready == nil {
|
||||||
@ -680,7 +680,7 @@ func (ac *addrConn) wait(ctx context.Context, failFast bool) (transport.ClientTr
|
|||||||
ac.mu.Lock()
|
ac.mu.Lock()
|
||||||
if ac.state == TransientFailure && failFast {
|
if ac.state == TransientFailure && failFast {
|
||||||
ac.mu.Unlock()
|
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()
|
ac.mu.Unlock()
|
||||||
|
|
||||||
|
@ -185,7 +185,8 @@ func Trailer(md *metadata.MD) CallOption {
|
|||||||
// connections or unreachable servers. If failfast is true, the RPC will fail
|
// 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
|
// 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 {
|
func FailFast(failFast bool) CallOption {
|
||||||
return beforeCall(func(c *callInfo) error {
|
return beforeCall(func(c *callInfo) error {
|
||||||
c.failFast = failFast
|
c.failFast = failFast
|
||||||
|
@ -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 {
|
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)
|
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.
|
// 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.Canceled {
|
if _, err := tc.EmptyCall(context.Background(), &testpb.Empty{}); grpc.Code(err) != codes.Unavailable {
|
||||||
t.Fatalf("TestService/EmptyCall(_, _, _) = _, %v, want _, error code: %d", err, codes.Canceled)
|
t.Fatalf("TestService/EmptyCall(_, _, _) = _, %v, want _, error code: %d", err, codes.Unavailable)
|
||||||
}
|
}
|
||||||
if _, err := tc.StreamingInputCall(ctx); grpc.Code(err) != codes.Canceled {
|
if _, err := tc.StreamingInputCall(ctx); grpc.Code(err) != codes.Unavailable {
|
||||||
t.Fatalf("TestService/StreamingInputCall(_) = _, %v, want _, error code: %d", err, codes.Canceled)
|
t.Fatalf("TestService/StreamingInputCall(_) = _, %v, want _, error code: %d", err, codes.Unavailable)
|
||||||
}
|
}
|
||||||
|
|
||||||
awaitNewConnLogOutput()
|
awaitNewConnLogOutput()
|
||||||
|
Reference in New Issue
Block a user