Skip to content

Commit

Permalink
clientv3/balancer: only notify live addresses to gRPC
Browse files Browse the repository at this point in the history
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Nov 8, 2017
1 parent d7a26cd commit be80e48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion clientv3/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,10 @@ func (b *simpleBalancer) notifyAddrs(msg notifyMsg) {
}
}
b.mu.RLock()
addrs := b.addrs
pinAddr := b.pinAddr
downc := b.downc
b.mu.RUnlock()
addrs := b.liveAddrs()

var waitDown bool
if pinAddr != "" {
Expand Down
8 changes: 4 additions & 4 deletions clientv3/balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func TestBalancerGetUnblocking(t *testing.T) {
}

down1(errors.New("error"))
if addrs := <-sb.Notify(); len(addrs) != len(endpoints) {
t.Errorf("closing the only connection should triggered balancer to send the all endpoints via Notify chan so that we can establish a connection")
if addrs := <-sb.Notify(); len(addrs) != 2 {
t.Errorf("closing the only connection should triggered balancer to send the 2 endpoints via Notify chan so that we can establish a connection")
}
down2(errors.New("error"))
_, _, err = sb.Get(context.Background(), unblockingOpts)
Expand Down Expand Up @@ -121,8 +121,8 @@ func TestBalancerGetBlocking(t *testing.T) {
}

down1(errors.New("error"))
if addrs := <-sb.Notify(); len(addrs) != len(endpoints) {
t.Errorf("closing the only connection should triggered balancer to send the all endpoints via Notify chan so that we can establish a connection")
if addrs := <-sb.Notify(); len(addrs) != 2 {
t.Errorf("closing the only connection should triggered balancer to send the 2 endpoints via Notify chan so that we can establish a connection")
}
down2(errors.New("error"))
ctx, cancel = context.WithTimeout(context.Background(), time.Millisecond*100)
Expand Down

0 comments on commit be80e48

Please sign in to comment.