Skip to content

Commit

Permalink
FailFast(false), return helpful error message when context is time out
Browse files Browse the repository at this point in the history
  • Loading branch information
yuqitao committed Apr 25, 2019
1 parent 3fc7430 commit 27a8866
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions picker_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ func (bp *pickerWrapper) pick(ctx context.Context, failfast bool, opts balancer.
bp.mu.Unlock()
select {
case <-ctx.Done():
if bp.connectionError() != nil {
switch ctx.Err() {
case context.DeadlineExceeded:
return nil, nil, status.Errorf(codes.DeadlineExceeded, "latest connection error: %v", bp.connectionError())
case context.Canceled:
return nil, nil, status.Errorf(codes.Canceled, "latest connection error: %v", bp.connectionError())
}
}
return nil, nil, ctx.Err()
case <-ch:
}
Expand Down

0 comments on commit 27a8866

Please sign in to comment.