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

Method Close

services/failure_watcher.go:80–100  ·  view source on GitHub ↗

Close stops this failure watcher and closes channel returned by Chan() method. After closing failure watcher, it cannot be used to watch additional services or managers. Repeated calls to Close() do nothing.

()

Source from the content-addressed store, hash-verified

78// it cannot be used to watch additional services or managers.
79// Repeated calls to Close() do nothing.
80func (w *FailureWatcher) Close() {
81 // Graceful handle the case FailureWatcher has not been initialized,
82 // to simplify the code in the components using it.
83 if w == nil {
84 return
85 }
86
87 w.mu.Lock()
88 defer w.mu.Unlock()
89
90 if w.closed {
91 return
92 }
93 for _, stop := range w.unregisterListeners {
94 stop()
95 }
96
97 // All listeners are now stopped, and can't receive more notifications. We can close the channel.
98 close(w.ch)
99 w.closed = true
100}

Callers 2

Calls

no outgoing calls

Tested by 2