Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: refactor clientv3 balancer, upgrade gRPC to v1.7.2 #8840

Merged
merged 5 commits into from
Nov 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
439 changes: 0 additions & 439 deletions clientv3/balancer.go

This file was deleted.

19 changes: 16 additions & 3 deletions clientv3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ func (c *Client) SetEndpoints(eps ...string) {
c.cfg.Endpoints = eps
c.mu.Unlock()
c.balancer.updateAddrs(eps...)

// updating notifyCh can trigger new connections,
// need update addrs if all connections are down
// or addrs does not include pinAddr.
c.balancer.mu.RLock()
update := !hasAddr(c.balancer.addrs, c.balancer.pinAddr)
c.balancer.mu.RUnlock()
if update {
select {
case c.balancer.updateAddrsC <- notifyNext:
case <-c.balancer.stopc:
}
}
}

// Sync synchronizes client's endpoints with the known endpoints from the etcd membership.
Expand Down Expand Up @@ -378,9 +391,9 @@ func newClient(cfg *Config) (*Client, error) {
client.Password = cfg.Password
}

sb := newSimpleBalancer(cfg.Endpoints)
hc := func(ep string) (bool, error) { return grpcHealthCheck(client, ep) }
client.balancer = newHealthBalancer(sb, cfg.DialTimeout, hc)
client.balancer = newHealthBalancer(cfg.Endpoints, cfg.DialTimeout, func(ep string) (bool, error) {
return grpcHealthCheck(client, ep)
})

// use Endpoints[0] so that for https:// without any tls config given, then
// grpc will assume the certificate server name is the endpoint host.
Expand Down
Loading