Explorar o código

the list of hosts can be empty

Chris Bannister %!s(int64=10) %!d(string=hai) anos
pai
achega
be24db38e1
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      ring.go

+ 3 - 0
ring.go

@@ -26,6 +26,9 @@ func (r *ring) rrHost() *HostInfo {
 	// for the control connection, should we also provide an iterator?
 	r.mu.RLock()
 	defer r.mu.RUnlock()
+	if len(r.hostList) == 0 {
+		return nil
+	}
 
 	pos := int(atomic.AddUint32(&r.pos, 1) - 1)
 	return r.hostList[pos%len(r.hostList)]