MCPcopy Create free account
hub / github.com/cortexproject/cortex / NewDNSWatcher

Function NewDNSWatcher

pkg/util/dns_watcher.go:30–46  ·  view source on GitHub ↗

NewDNSWatcher creates a new DNS watcher and returns a service that is wrapping it.

(address string, dnsLookupPeriod time.Duration, notifications DNSNotifications)

Source from the content-addressed store, hash-verified

28
29// NewDNSWatcher creates a new DNS watcher and returns a service that is wrapping it.
30func NewDNSWatcher(address string, dnsLookupPeriod time.Duration, notifications DNSNotifications) (services.Service, error) {
31 resolver, err := grpcutil.NewDNSResolverWithFreq(dnsLookupPeriod, util_log.Logger)
32 if err != nil {
33 return nil, err
34 }
35
36 watcher, err := resolver.Resolve(address, "")
37 if err != nil {
38 return nil, err
39 }
40
41 w := &dnsWatcher{
42 watcher: watcher,
43 notifications: notifications,
44 }
45 return services.NewBasicService(nil, w.watchDNSLoop, nil), nil
46}
47
48// watchDNSLoop watches for changes in DNS and sends notifications.
49func (w *dnsWatcher) watchDNSLoop(servCtx context.Context) error {

Callers 2

Calls 3

NewDNSResolverWithFreqFunction · 0.92
NewBasicServiceFunction · 0.92
ResolveMethod · 0.65

Tested by

no test coverage detected