initSerf initializes serf and advertizes this nodes RPC port to other nodes.
(config *serf.Config)
| 133 | |
| 134 | // initSerf initializes serf and advertizes this nodes RPC port to other nodes. |
| 135 | func (n *Node) initSerf(config *serf.Config) error { |
| 136 | config.NodeName = n.name |
| 137 | config.EventCh = n.eventCh |
| 138 | |
| 139 | // Advertize the RPC port |
| 140 | tags := map[string]string{ |
| 141 | externalRpcTag: strconv.Itoa(n.port), |
| 142 | } |
| 143 | |
| 144 | config.Tags = tags |
| 145 | |
| 146 | // Start serf for discovery |
| 147 | s, err := serf.Create(config) |
| 148 | if err != nil { |
| 149 | return err |
| 150 | } |
| 151 | |
| 152 | n.serf = s |
| 153 | return nil |
| 154 | } |
| 155 | |
| 156 | // serfEventHandler is a dispatch method on Serf Events. Should be started in a |
| 157 | // goroutine. |