Skip to content

Commit 302d631

Browse files
authored
Allow more memberlist configuration (#65)
* Allow configuring the gossip interval * Support configuration for handoff queue * Logs nodes contacted on bootstrap * Don't announceMembers all the time
1 parent c7779d9 commit 302d631

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

config/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ type SidecarConfig struct {
4444
StatsAddr string `envconfig:"STATS_ADDR"`
4545
PushPullInterval time.Duration `envconfig:"PUSH_PULL_INTERVAL" default:"20s"`
4646
GossipMessages int `envconfig:"GOSSIP_MESSAGES" default:"15"`
47+
GossipInterval time.Duration `envconfig:"GOSSIP_INTERVAL" default:"200ms"`
48+
HandoffQueueDepth int `envconfig:"HANDOFF_QUEUE_DEPTH" default:"1024"`
4749
LoggingFormat string `envconfig:"LOGGING_FORMAT"`
4850
LoggingLevel string `envconfig:"LOGGING_LEVEL" default:"info"`
4951
DefaultCheckEndpoint string `envconfig:"DEFAULT_CHECK_ENDPOINT" default:"/version"`

main.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ func configureMemberlist(config *config.Config, state *catalog.ServicesState) *m
247247
if config.Sidecar.GossipMessages != 0 {
248248
mlConfig.GossipMessages = config.Sidecar.GossipMessages
249249
}
250+
mlConfig.GossipInterval = config.Sidecar.GossipInterval
251+
mlConfig.HandoffQueueDepth = config.Sidecar.HandoffQueueDepth
250252

251253
// Make sure we pass on the cluster name to Memberlist
252254
mlConfig.ClusterName = config.Sidecar.ClusterName
@@ -297,8 +299,9 @@ func main() {
297299
exitWithError(err, "Failed to create memberlist")
298300

299301
// Join an existing cluster by specifying at least one known member.
300-
_, err = list.Join(config.Sidecar.Seeds)
302+
nodeCount, err := list.Join(config.Sidecar.Seeds)
301303
exitWithError(err, "Failed to join cluster")
304+
log.Info("Joined cluster with %d nodes contacted", nodeCount)
302305

303306
// Set up a bunch of go-director Loopers to run our
304307
// background goroutines
@@ -358,7 +361,12 @@ func main() {
358361
go proxy.Watch(state)
359362
}
360363

361-
go announceMembers(list, state)
364+
// This is kind of expensive because it looks at the state and formats text
365+
// output on an ongoing basis. Only run in debug mode.
366+
if config.Debug {
367+
go announceMembers(list, state)
368+
}
369+
362370
go state.BroadcastServices(serviceFunc, servicesLooper)
363371
go state.BroadcastTombstones(serviceFunc, tombstoneLooper)
364372
go state.TrackNewServices(serviceFunc, trackingLooper)

0 commit comments

Comments
 (0)