MCPcopy Create free account
hub / github.com/coder/coder / handleWatchedConfigChange

Method handleWatchedConfigChange

agent/x/agentmcp/manager.go:357–378  ·  view source on GitHub ↗

handleWatchedConfigChange is invoked by the watcher on a debounced fire. It triggers a singleflight Reload using the most recently observed path set so the cached server map and snapshot are refreshed without waiting for the next HTTP request.

()

Source from the content-addressed store, hash-verified

355// snapshot are refreshed without waiting for the next HTTP
356// request.
357func (m *Manager) handleWatchedConfigChange() {
358 m.mu.RLock()
359 paths := slices.Clone(m.lastPaths)
360 closed := m.closed
361 m.mu.RUnlock()
362 if closed || len(paths) == 0 {
363 return
364 }
365
366 logger := m.logger.With(slog.F("trigger", "fsnotify"))
367 logger.Debug(m.ctx, "reloading due to config change")
368 if err := m.Reload(m.ctx, paths); err != nil {
369 if errors.Is(err, ErrManagerClosed) ||
370 errors.Is(err, context.Canceled) {
371 logger.Debug(m.ctx,
372 "watched reload short-circuited by shutdown",
373 slog.Error(err))
374 return
375 }
376 logger.Warn(m.ctx, "watched reload failed", slog.Error(err))
377 }
378}
379
380func (m *Manager) waitReload(ctx context.Context, ch <-chan reloadResult, timeout time.Duration) error {
381 // Prefer caller cancellation when it already happened before the

Callers

nothing calls this directly

Calls 4

ReloadMethod · 0.95
CloneMethod · 0.45
IsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected