MCPcopy
hub / github.com/grafana/dskit / WatchManager

Method WatchManager

services/failure_watcher.go:57–75  ·  view source on GitHub ↗
(manager *Manager)

Source from the content-addressed store, hash-verified

55}
56
57func (w *FailureWatcher) WatchManager(manager *Manager) {
58 // Ensure that if the caller request to watch services, then the FailureWatcher
59 // has been initialized.
60 if w == nil {
61 panic(errFailureWatcherNotInitialized)
62 }
63
64 w.mu.Lock()
65 defer w.mu.Unlock()
66
67 if w.closed {
68 panic(errFailureWatcherClosed)
69 }
70
71 stop := manager.AddListener(NewManagerListener(nil, nil, func(service Service) {
72 w.ch <- errors.Wrapf(service.FailureCase(), "service %s failed", DescribeService(service))
73 }))
74 w.unregisterListeners = append(w.unregisterListeners, stop)
75}
76
77// Close stops this failure watcher and closes channel returned by Chan() method. After closing failure watcher,
78// it cannot be used to watch additional services or managers.

Callers 2

Calls 4

NewManagerListenerFunction · 0.85
DescribeServiceFunction · 0.85
AddListenerMethod · 0.65
FailureCaseMethod · 0.65

Tested by 2