Skip to content

Commit

Permalink
stateless drop, stop when drop
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Apr 10, 2019
1 parent a680b04 commit 8b1a2cc
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions balancer/xds/edsbalancer/edsbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,10 @@ func newDropPicker(p balancer.Picker, drops []*dropper) *dropPicker {
func (d *dropPicker) Pick(ctx context.Context, opts balancer.PickOptions) (conn balancer.SubConn, done func(balancer.DoneInfo), err error) {
var drop bool
for _, dp := range d.drops {
// It's necessary to call drop on all droppers if the droppers are
// stateful. For example, if the second drop only drops 1/2, and only
// drops even number picks, we need to call it's drop() even if the
// first dropper already returned true.
//
// It won't be necessary if droppers are stateless, like toss a coin.
drop = drop || dp.drop()
if dp.drop() {
drop = true
break
}
}
if drop {
return nil, nil, status.Errorf(codes.Unavailable, "RPC is dropped")
Expand Down

0 comments on commit 8b1a2cc

Please sign in to comment.