func selectRandomWeighted(connections []*ClusterConnectionInfo, weights []int) *ClusterConnectionInfo {
	sum := 0
	for _, weight := range weights {
		sum += weight
	}

	if sum <= 0 {
		return nil
	}

	randValue := rand.Intn(sum)
	sum = 0
	for i, weight := range weights {
		sum += weight
		if randValue < sum {
			return connections[i]
		}
	}
	return nil
}
// selectRandomWeighted selects a ClusterConnectionInfo info from a weighted list of ClusterConnectionInfo
selectRandomWeighted selects a ClusterConnectionInfo info from a weighted list of ClusterConnectionInfo
// selectRandomWeighted selects a ClusterConnectionInfo info from a weighted list of ClusterConnectionInfo
func selectRandomWeighted(connections []*ClusterConnectionInfo, weights []int) *ClusterConnectionInfo {
	sum := 0
	for _, weight := range weights {
		sum += weight
	}
	if sum <= 0 {
		return nil
	}
	randValue := rand.Intn(sum)
	sum = 0
	for i, weight := range weights {
		sum += weight
		if randValue < sum {
			return connections[i]
		}
	}
	return nil
}
func selectRandomWeighted ( connections [ ] * ClusterConnectionInfo , weights [ ] int ) * ClusterConnectionInfo { sum := 0 for _ , weight := range weights { sum += weight } if sum <= 0 { return nil } randValue := rand . Intn ( sum ) sum = 0 for i , weight := range weights { sum += weight if randValue < sum { return connections [ i ] } } return nil }
selectRandomWeighted selects a ClusterConnectionInfo info from a weighted list of ClusterConnectionInfo
selectRandomWeighted selects a ClusterConnectionInfo info from a weighted list of ClusterConnectionInfo