|
|
@@ -97,23 +97,21 @@ func (h *ringDescriber) run(sleep time.Duration) {
|
|
|
}
|
|
|
|
|
|
for {
|
|
|
- // if we have 0 hosts this will return the previous list of hosts to
|
|
|
- // attempt to reconnect to the cluster otherwise we would never find
|
|
|
- // downed hosts again, could possibly have an optimisation to only
|
|
|
- // try to add new hosts if GetHosts didnt error and the hosts didnt change.
|
|
|
- hosts, partitioner, err := h.GetHosts()
|
|
|
- if err != nil {
|
|
|
- log.Println("RingDescriber: unable to get ring topology:", err)
|
|
|
- } else {
|
|
|
- h.session.Pool.SetHosts(hosts)
|
|
|
- if v, ok := h.session.Pool.(SetPartitioner); ok {
|
|
|
- v.SetPartitioner(partitioner)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- time.Sleep(sleep)
|
|
|
-
|
|
|
select {
|
|
|
+ case <-time.After(sleep):
|
|
|
+ // if we have 0 hosts this will return the previous list of hosts to
|
|
|
+ // attempt to reconnect to the cluster otherwise we would never find
|
|
|
+ // downed hosts again, could possibly have an optimisation to only
|
|
|
+ // try to add new hosts if GetHosts didnt error and the hosts didnt change.
|
|
|
+ hosts, partitioner, err := h.GetHosts()
|
|
|
+ if err != nil {
|
|
|
+ log.Println("RingDescriber: unable to get ring topology:", err)
|
|
|
+ } else {
|
|
|
+ h.session.Pool.SetHosts(hosts)
|
|
|
+ if v, ok := h.session.Pool.(SetPartitioner); ok {
|
|
|
+ v.SetPartitioner(partitioner)
|
|
|
+ }
|
|
|
+ }
|
|
|
case <-h.closeChan:
|
|
|
return
|
|
|
}
|