Skip to content

Commit

Permalink
implement route() using topology methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gdiazlo committed Nov 23, 2018
1 parent f98f898 commit 94981c8
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions gossip/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,19 @@ func (a *Agent) sendOutQueue() {

}

func (a Agent) route(s *member.Peer) []*memberlist.Node {
return nil
func (a Agent) route(src *member.Peer) []*memberlist.Node {
var excluded PeerList

dst := make([]*memberlist.Node, 0)

excluded.L = append(excluded.L, src)
excluded.L = append(excluded.L, a.Self)

peers := a.Topology.Each(2, &excluded)
for _, p := range peers.L {
dst = append(dst, p.Node())
}
return dst
}

// Join asks the Agent instance to join.
Expand All @@ -170,7 +181,6 @@ func (a *Agent) Join(addrs []string) (int, error) {
}

if len(addrs) > 0 {
log.Debugf("Trying to join the cluster using members: %v", addrs)
return a.memberlist.Join(addrs)
}
return 0, nil
Expand Down

0 comments on commit 94981c8

Please sign in to comment.