Skip to content

Commit

Permalink
Update start code with new agent
Browse files Browse the repository at this point in the history
  • Loading branch information
gdiazlo committed Nov 22, 2018
1 parent 2548b3f commit 3e324a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
21 changes: 11 additions & 10 deletions cmd/agent_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import (
"syscall"

"github.com/bbva/qed/gossip"
"github.com/bbva/qed/gossip/auditor"
"github.com/bbva/qed/gossip/monitor"
"github.com/bbva/qed/gossip/member"
"github.com/bbva/qed/log"
"github.com/spf13/cobra"
)
Expand All @@ -44,19 +43,20 @@ func newAgentStartCommand() *cobra.Command {
config.NodeName = nodeName
config.BindAddr = bindAddr
config.AdvertiseAddr = advertiseAddr
config.Role = gossip.NewNodeType(role)
config.Role = member.ParseType(role)
config.EnableCompression = true

var agent *gossip.Agent
var err error

switch config.Role {
case gossip.PublisherType:
case gossip.MonitorType:
conf := monitor.DefaultConfig()
agent, err = gossip.Create(config, monitor.NewMonitorHandlerBuilder(conf))
case gossip.AuditorType:
conf := auditor.DefaultConfig()
agent, err = gossip.Create(config, auditor.NewAuditorHandlerBuilder(conf))
case member.Publisher:
case member.Monitor:
// conf := monitor.DefaultConfig()
agent, err = gossip.NewAgent(config, []gossip.Processor{gossip.DummyProcessor{}})
case member.Auditor:
// conf := auditor.DefaultConfig()
agent, err = gossip.NewAgent(config, []gossip.Processor{gossip.DummyProcessor{}})
default:
log.Fatalf("Failed to start the QED agent: unknown role")
}
Expand All @@ -70,6 +70,7 @@ func newAgentStartCommand() *cobra.Command {
}
log.Debugf("Number of nodes contacted: %d", contacted)

agent.Start()
defer agent.Shutdown()
awaitTermSignal(agent.Leave)

Expand Down
5 changes: 3 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/bbva/qed/api/mgmthttp"
"github.com/bbva/qed/api/tampering"
"github.com/bbva/qed/gossip"
"github.com/bbva/qed/gossip/member"
"github.com/bbva/qed/gossip/sender"
"github.com/bbva/qed/hashing"
"github.com/bbva/qed/log"
Expand Down Expand Up @@ -137,8 +138,8 @@ func NewServer(
// Create gossip agent
config := gossip.DefaultConfig()
config.BindAddr = gossipAddr
config.Role = gossip.ServerType
server.agent, err = gossip.Create(config, gossip.NewNopMessageHandler)
config.Role = member.Server
server.agent, err = gossip.NewAgent(config, nil)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 3e324a0

Please sign in to comment.