Kaynağa Gözat

pool: only add hosts if they are up

Chris Bannister 10 yıl önce
ebeveyn
işleme
0248bf8a96
1 değiştirilmiş dosya ile 3 ekleme ve 1 silme
  1. 3 1
      connectionpool.go

+ 3 - 1
connectionpool.go

@@ -139,7 +139,7 @@ func (p *policyConnPool) SetHosts(hosts []*HostInfo) {
 	// created before returning
 	// created before returning
 	for _, host := range hosts {
 	for _, host := range hosts {
 		pool, exists := p.hostConnPools[host.Peer()]
 		pool, exists := p.hostConnPools[host.Peer()]
-		if !exists {
+		if !exists && host.IsUp() {
 			// create a connection pool for the host
 			// create a connection pool for the host
 			pool = newHostConnPool(
 			pool = newHostConnPool(
 				p.session,
 				p.session,
@@ -500,6 +500,8 @@ func (pool *hostConnPool) HandleError(conn *Conn, err error, closed bool) {
 		return
 		return
 	}
 	}
 
 
+	// TODO: track the number of errors per host and detect when a host is dead,
+	// then also have something which can detect when a host comes back.
 	pool.mu.Lock()
 	pool.mu.Lock()
 	defer pool.mu.Unlock()
 	defer pool.mu.Unlock()