diff --git a/internal/server/options.go b/internal/server/options.go index 9fc51e1429..391c499d4d 100644 --- a/internal/server/options.go +++ b/internal/server/options.go @@ -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 + } +} diff --git a/internal/server/options_test.go b/internal/server/options_test.go index 6b9ffec030..d816e5758a 100644 --- a/internal/server/options_test.go +++ b/internal/server/options_test.go @@ -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) + }) }