Skip to content

Commit df6904f

Browse files
authored
Merge pull request #209 from uber/add_opt
Allow RequiresAppInPing to be configured
2 parents 6de1373 + 7e7886b commit df6904f

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

options.go

+13
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ type configuration struct {
5959

6060
// SelfEvict holds the settings with regards to self eviction
6161
SelfEvict swim.SelfEvictOptions
62+
63+
// RequiresAppInPing configures if ringpop node should reject pings
64+
// that don't contain app name
65+
RequiresAppInPing bool
6266
}
6367

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

362+
// RequiresAppInPing configures if ringpop node should reject pings
363+
// that don't contain app name
364+
func RequiresAppInPing(requiresAppInPing bool) Option {
365+
return func(r *Ringpop) error {
366+
r.config.RequiresAppInPing = requiresAppInPing
367+
return nil
368+
}
369+
}
370+
358371
// Default options
359372

360373
// defaultClock sets the ringpop clock interface to use the system clock

ringpop.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,12 @@ func (rp *Ringpop) init() error {
191191
rp.registerHandlers()
192192

193193
rp.node = swim.NewNode(rp.config.App, address, rp.subChannel, &swim.Options{
194-
StateTimeouts: rp.config.StateTimeouts,
195-
Clock: rp.clock,
196-
LabelLimits: rp.config.LabelLimits,
197-
InitialLabels: rp.config.InitialLabels,
198-
SelfEvict: rp.config.SelfEvict,
194+
StateTimeouts: rp.config.StateTimeouts,
195+
Clock: rp.clock,
196+
LabelLimits: rp.config.LabelLimits,
197+
InitialLabels: rp.config.InitialLabels,
198+
SelfEvict: rp.config.SelfEvict,
199+
RequiresAppInPing: rp.config.RequiresAppInPing,
199200
})
200201
rp.node.AddListener(rp)
201202

ringpop_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ func (s *RingpopTestSuite) SetupTest() {
110110
LabelLimitCount(1),
111111
LabelLimitKeySize(5),
112112
LabelLimitValueSize(5),
113+
RequiresAppInPing(true),
113114
)
114115
s.NoError(err, "Ringpop must create successfully")
115116

0 commit comments

Comments
 (0)