Join is used to take an existing Memberlist and attempt to Join a cluster by contacting all the given hosts and performing a state sync. Initially, the Memberlist only contains our own state, so doing this will cause remote nodes to become aware of the existence of this node, effectively joining the
()
| 194 | // the Memberlist only contains our own state, so doing this will cause remote |
| 195 | // nodes to become aware of the existence of this node, effectively joining the cluster. |
| 196 | func (d *Discovery) Join() (int, error) { |
| 197 | if d.serviceDiscovery != nil { |
| 198 | peers, err := d.serviceDiscovery.DiscoverPeers() |
| 199 | if err != nil { |
| 200 | return 0, err |
| 201 | } |
| 202 | return d.memberlist.Join(peers) |
| 203 | } |
| 204 | return d.memberlist.Join(d.config.Peers) |
| 205 | } |
| 206 | |
| 207 | func (d *Discovery) Rejoin(peers []string) (int, error) { |
| 208 | return d.memberlist.Join(peers) |