Skip to content

Commit 27a8866

Browse files
committed
FailFast(false), return helpful error message when context is time out
1 parent 3fc7430 commit 27a8866

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: picker_wrapper.go

+8
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ func (bp *pickerWrapper) pick(ctx context.Context, failfast bool, opts balancer.
120120
bp.mu.Unlock()
121121
select {
122122
case <-ctx.Done():
123+
if bp.connectionError() != nil {
124+
switch ctx.Err() {
125+
case context.DeadlineExceeded:
126+
return nil, nil, status.Errorf(codes.DeadlineExceeded, "latest connection error: %v", bp.connectionError())
127+
case context.Canceled:
128+
return nil, nil, status.Errorf(codes.Canceled, "latest connection error: %v", bp.connectionError())
129+
}
130+
}
123131
return nil, nil, ctx.Err()
124132
case <-ch:
125133
}

0 commit comments

Comments
 (0)