Skip to content

Commit

Permalink
Allow RequiresAppInPing to be configured
Browse files Browse the repository at this point in the history
  • Loading branch information
yulunli committed Jun 22, 2017
1 parent 6de1373 commit 7e7886b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
13 changes: 13 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ type configuration struct {

// SelfEvict holds the settings with regards to self eviction
SelfEvict swim.SelfEvictOptions

// RequiresAppInPing configures if ringpop node should reject pings
// that don't contain app name
RequiresAppInPing bool
}

// An Option is a modifier functions that configure/modify a real Ringpop
Expand Down Expand Up @@ -355,6 +359,15 @@ func SelfEvictPingRatio(ratio float64) Option {
}
}

// RequiresAppInPing configures if ringpop node should reject pings
// that don't contain app name
func RequiresAppInPing(requiresAppInPing bool) Option {
return func(r *Ringpop) error {
r.config.RequiresAppInPing = requiresAppInPing
return nil
}
}

// Default options

// defaultClock sets the ringpop clock interface to use the system clock
Expand Down
11 changes: 6 additions & 5 deletions ringpop.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,12 @@ func (rp *Ringpop) init() error {
rp.registerHandlers()

rp.node = swim.NewNode(rp.config.App, address, rp.subChannel, &swim.Options{
StateTimeouts: rp.config.StateTimeouts,
Clock: rp.clock,
LabelLimits: rp.config.LabelLimits,
InitialLabels: rp.config.InitialLabels,
SelfEvict: rp.config.SelfEvict,
StateTimeouts: rp.config.StateTimeouts,
Clock: rp.clock,
LabelLimits: rp.config.LabelLimits,
InitialLabels: rp.config.InitialLabels,
SelfEvict: rp.config.SelfEvict,
RequiresAppInPing: rp.config.RequiresAppInPing,
})
rp.node.AddListener(rp)

Expand Down
1 change: 1 addition & 0 deletions ringpop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func (s *RingpopTestSuite) SetupTest() {
LabelLimitCount(1),
LabelLimitKeySize(5),
LabelLimitValueSize(5),
RequiresAppInPing(true),
)
s.NoError(err, "Ringpop must create successfully")

Expand Down

0 comments on commit 7e7886b

Please sign in to comment.