MCPcopy
hub / github.com/gogf/gf / StopWatch

Method StopWatch

os/gcfg/gcfg_loader.go:225–239  ·  view source on GitHub ↗

StopWatch stops watching for configuration changes and removes the associated watcher

(ctx context.Context)

Source from the content-addressed store, hash-verified

223
224// StopWatch stops watching for configuration changes and removes the associated watcher
225func (l *Loader[T]) StopWatch(ctx context.Context) (bool, error) {
226 l.mutex.Lock()
227 defer l.mutex.Unlock()
228
229 if l.watcherName == "" {
230 return false, gerror.New("No watcher name specified")
231 }
232 adapter := l.config.GetAdapter()
233 if watcherAdapter, ok := adapter.(WatcherAdapter); ok {
234 watcherAdapter.RemoveWatcher(l.watcherName)
235 l.watcherName = ""
236 return true, nil
237 }
238 return false, gerror.New("Watcher adapter not found")
239}
240
241// IsWatching returns true if the loader is currently watching for configuration changes
242func (l *Loader[T]) IsWatching() bool {

Calls 5

NewFunction · 0.92
RemoveWatcherMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
GetAdapterMethod · 0.45