github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/providers/discovery/puppetdb/options.go (about) 1 // Copyright (c) 2021, R.I. Pienaar and the Choria Project contributors 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 package puppetdb 6 7 import ( 8 "sync" 9 "time" 10 11 "github.com/choria-io/go-choria/protocol" 12 ) 13 14 type dOpts struct { 15 filter *protocol.Filter 16 collective string 17 discovered []string 18 mu *sync.Mutex 19 timeout time.Duration 20 } 21 22 // DiscoverOption configures the broadcast discovery method 23 type DiscoverOption func(o *dOpts) 24 25 // Filter sets the filter to use for the discovery, else a blank one is used 26 func Filter(f *protocol.Filter) DiscoverOption { 27 return func(o *dOpts) { 28 o.filter = f 29 } 30 } 31 32 // Collective sets the collective to discover in, else main collective is used 33 func Collective(c string) DiscoverOption { 34 return func(o *dOpts) { 35 o.collective = c 36 } 37 } 38 39 // Timeout sets the discovery timeout, else the configured default is used 40 func Timeout(t time.Duration) DiscoverOption { 41 return func(o *dOpts) { 42 o.timeout = t 43 } 44 }