Skip to content

Commit

Permalink
Start gossip agent in a separate goroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
aalda committed Nov 29, 2018
1 parent 6b47c3e commit 91e6507
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
1 change: 0 additions & 1 deletion cmd/agent_auditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func newAgentAuditorCommand(ctx *agentContext) *cobra.Command {
}
log.Debugf("Number of nodes contacted: %d (%v)", contacted, agentConfig.StartJoin)

agent.Start()
defer agent.Shutdown()
util.AwaitTermSignal(agent.Leave)
},
Expand Down
1 change: 0 additions & 1 deletion cmd/agent_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func newAgentMonitorCommand(ctx *agentContext) *cobra.Command {
}
log.Debugf("Number of nodes contacted: %d", contacted)

agent.Start()
defer agent.Shutdown()
util.AwaitTermSignal(agent.Leave)
},
Expand Down
1 change: 0 additions & 1 deletion cmd/agent_publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func newAgentPublisherCommand(ctx *agentContext) *cobra.Command {
}
log.Debugf("Number of nodes contacted: %d", contacted)

agent.Start()
defer agent.Shutdown()
util.AwaitTermSignal(agent.Leave)
},
Expand Down
6 changes: 5 additions & 1 deletion gossip/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,14 @@ func NewAgent(conf *Config, p []Processor) (agent *Agent, err error) {
RetransmitMult: 2,
}

if p != nil {
go agent.start()
}

return agent, nil
}

func (a *Agent) Start() {
func (a *Agent) start() {

outTicker := time.NewTicker(2 * time.Second)
alertTicker := time.NewTicker(1 * time.Second)
Expand Down
4 changes: 0 additions & 4 deletions gossip/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import (
"github.com/bbva/qed/gossip/member"
)

func TestStart(t *testing.T) {

}

func TestJoin(t *testing.T) {
conf := DefaultConfig()
conf.NodeName = "testNode"
Expand Down
3 changes: 3 additions & 0 deletions gossip/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func (e *eventDelegate) NotifyLeave(n *memberlist.Node) {
// updated, usually involving the meta data.
func (e *eventDelegate) NotifyUpdate(n *memberlist.Node) {
// ignore
peer := member.ParsePeer(n)
e.agent.Topology.Update(peer)
log.Debugf("member updated: %+v ", peer)
}

type agentDelegate struct {
Expand Down

0 comments on commit 91e6507

Please sign in to comment.