func (s *Setting) ChooseNextServer() (srv ServerHostPort, ok bool) {
	s.mu.Lock()
	defer s.mu.Unlock()
	cnt := len(s.Servers)
	for i := 0; i < cnt; i++ {
		s.curServerIdx = (s.curServerIdx + 1) % cnt
		el := s.Servers[s.curServerIdx]
		if _, ok := s.brokenHosts[el.HostPort]; ok {
			continue
		}
		if s.curMaxWeight > 0 && uint32(rand.Intn(int(s.curMaxWeight))+1) > el.Weight {
			continue
		}
		return el.HostPort, true
	}
	return "", false
}
ChooseNextServer returns next server from the list or ok=false, which means that there are no available hosts
package destination
import (
	"log"
	"math/rand"
	"sync"
	"time"
)
type (
	ServersStr string
	ServerHostPort string
	Server struct {
		HostPort ServerHostPort
		Weight   uint32
	}
	Map map[ServersStr]*Setting
	Setting struct {
		Default bool
		Servers []Server
		Tables  []string
		mu           sync.Mutex
		curServerIdx int
		curMaxWeight uint32
		brokenHosts  map[ServerHostPort]time.Time
		stopCh       chan struct{}
	}
)
func NewSetting() *Setting {
	return &Setting{
		brokenHosts: make(map[ServerHostPort]time.Time),
		stopCh:      make(chan struct{}),
	}
}
func (s *Setting) Init() {
	s.mu.Lock()
	defer s.mu.Unlock()
	s.curServerIdx = -1  
	s.recalcMaxWeight()
}
func (s *Setting) Destroy() {
	close(s.stopCh)
}