(queryIdx int, wantLeader bool)
| 112 | } |
| 113 | |
| 114 | func (c *LocalCluster) findZero(queryIdx int, wantLeader bool) (*ZeroLocator, error) { |
| 115 | state, err := c.GetZeroState(queryIdx) |
| 116 | if err != nil { |
| 117 | return nil, err |
| 118 | } |
| 119 | for id, z := range state.Zeros { |
| 120 | if z.Leader != wantLeader { |
| 121 | continue |
| 122 | } |
| 123 | idx, ok := containerIdxFromAddr(z.Addr) |
| 124 | if !ok { |
| 125 | return nil, fmt.Errorf("cannot map addr %q to container index", z.Addr) |
| 126 | } |
| 127 | return &ZeroLocator{ContainerIdx: idx, RaftID: id, Addr: z.Addr}, nil |
| 128 | } |
| 129 | role := "follower" |
| 130 | if wantLeader { |
| 131 | role = "leader" |
| 132 | } |
| 133 | return nil, fmt.Errorf("no %s found in /state from zero%d", role, queryIdx) |
| 134 | } |
| 135 | |
| 136 | // WaitForZeroAddress polls /state until the member identified by raftID has |
| 137 | // wantAddr. It first tries queryIdx; if that node's /state is unavailable |
no test coverage detected