(nodes []clusterNode)
| 401 | } |
| 402 | |
| 403 | func normalizeClusterNodes(nodes []clusterNode) []clusterNode { |
| 404 | out := make([]clusterNode, 0, len(nodes)) |
| 405 | for _, node := range nodes { |
| 406 | node.IP = strings.TrimSpace(node.IP) |
| 407 | if node.IP == "" || node.Port <= 0 { |
| 408 | continue |
| 409 | } |
| 410 | if node.ClientCount < 0 { |
| 411 | node.ClientCount = 0 |
| 412 | } |
| 413 | out = append(out, node) |
| 414 | } |
| 415 | sort.SliceStable(out, func(i, j int) bool { |
| 416 | return out[i].ClientCount < out[j].ClientCount |
| 417 | }) |
| 418 | return out |
| 419 | } |
| 420 | |
| 421 | func (c *Client) switchToNodeLocked(node clusterNode) bool { |
| 422 | host := strings.TrimSpace(node.IP) |
no outgoing calls
no test coverage detected