|
@@ -45,6 +45,7 @@ type HostPool interface {
|
|
|
|
|
|
|
|
ResetAll()
|
|
ResetAll()
|
|
|
Hosts() []string
|
|
Hosts() []string
|
|
|
|
|
+ SetHosts([]string)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type standardHostPool struct {
|
|
type standardHostPool struct {
|
|
@@ -146,6 +147,26 @@ func (p *standardHostPool) ResetAll() {
|
|
|
p.doResetAll()
|
|
p.doResetAll()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func (p *standardHostPool) SetHosts(hosts []string) {
|
|
|
|
|
+ p.Lock()
|
|
|
|
|
+ defer p.Unlock()
|
|
|
|
|
+ p.setHosts(hosts)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (p *standardHostPool) setHosts(hosts []string) {
|
|
|
|
|
+ p.hosts = make(map[string]*hostEntry, len(hosts))
|
|
|
|
|
+ p.hostList = make([]*hostEntry, len(hosts))
|
|
|
|
|
+
|
|
|
|
|
+ for i, h := range hosts {
|
|
|
|
|
+ e := &hostEntry{
|
|
|
|
|
+ host: h,
|
|
|
|
|
+ retryDelay: p.initialRetryDelay,
|
|
|
|
|
+ }
|
|
|
|
|
+ p.hosts[h] = e
|
|
|
|
|
+ p.hostList[i] = e
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// this actually performs the logic to reset,
|
|
// this actually performs the logic to reset,
|
|
|
// and should only be called when the lock has
|
|
// and should only be called when the lock has
|
|
|
// already been acquired
|
|
// already been acquired
|