()
| 475 | } |
| 476 | |
| 477 | func (c *Client) switchToNextNodeLocked() (bool, string) { |
| 478 | currentHost := strings.TrimSpace(c.homeCfg.Host) |
| 479 | currentPort := c.homeCfg.Port |
| 480 | candidates := append([]clusterNode(nil), c.clusterNodes...) |
| 481 | if strings.TrimSpace(c.seedHost) != "" && c.seedPort > 0 { |
| 482 | candidates = append(candidates, clusterNode{IP: c.seedHost, Port: c.seedPort}) |
| 483 | } |
| 484 | for _, node := range candidates { |
| 485 | host := strings.TrimSpace(node.IP) |
| 486 | if host == "" || node.Port <= 0 { |
| 487 | continue |
| 488 | } |
| 489 | if host == currentHost && node.Port == currentPort { |
| 490 | continue |
| 491 | } |
| 492 | if c.switchToNodeLocked(clusterNode{IP: host, Port: node.Port}) { |
| 493 | addr, _ := c.addrLocked() |
| 494 | return true, addr |
| 495 | } |
| 496 | } |
| 497 | return false, "" |
| 498 | } |
| 499 | |
| 500 | func (c *Client) markSubscriptionTimeout() { |
| 501 | switched, addr := c.failoverAfterSubscriptionTimeout() |
no test coverage detected