Add options for directly connected worker (#2762)
This commit is contained in:
1 parent
ef6f94f496
commit
b7f0f455db
2 files changed
+16
No files matched your search
@@ -47,6 +47,7 @@ type options struct {
|
||||
withOperationalState string
|
||||
withActiveWorkers bool
|
||||
withFeature version.Feature
|
||||
withDirectlyConnected bool
|
||||
}
|
||||
|
||||
func getDefaultOptions() options {
|
||||
@@ -230,3 +231,10 @@ func WithFeature(feature version.Feature) Option {
|
||||
o.withFeature = feature
|
||||
}
|
||||
}
|
||||
|
||||
// WithDirectlyConnected provides an option to limit graph search to only directly connected workers
|
||||
func WithDirectlyConnected(conn bool) Option {
|
||||
return func(o *options) {
|
||||
o.withDirectlyConnected = conn
|
||||
}
|
||||
}
|
||||
@@ -217,4 +217,12 @@ func Test_GetOpts(t *testing.T) {
|
||||
testOpts.withNewIdFunc = nil
|
||||
assert.Equal(t, opts, testOpts)
|
||||
})
|
||||
t.Run("WithDirectlyConnected", func(t *testing.T) {
|
||||
opts := GetOpts(WithDirectlyConnected(true))
|
||||
testOpts := getDefaultOptions()
|
||||
testOpts.withDirectlyConnected = true
|
||||
opts.withNewIdFunc = nil
|
||||
testOpts.withNewIdFunc = nil
|
||||
assert.Equal(t, opts, testOpts)
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user