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

Method run

agent/x/agentmcp/configwatcher.go:215–236  ·  view source on GitHub ↗

run is the watcher loop. It exits when the underlying fsnotify.Watcher closes its channels or Close is called.

()

Source from the content-addressed store, hash-verified

213// run is the watcher loop. It exits when the underlying
214// fsnotify.Watcher closes its channels or Close is called.
215func (cw *configWatcher) run() {
216 defer close(cw.runDoneCh)
217 ctx := context.Background()
218 for {
219 select {
220 case <-cw.closedCh:
221 return
222 case evt, ok := <-cw.watcher.Events:
223 if !ok {
224 return
225 }
226 cw.handleEvent(ctx, evt)
227 case err, ok := <-cw.watcher.Errors:
228 if !ok {
229 return
230 }
231 cw.logger.Warn(ctx,
232 "fsnotify watch error; config file changes may not be detected until the next HTTP request",
233 slog.Error(err))
234 }
235 }
236}
237
238// handleEvent decides whether the event concerns one of the
239// watched files (or could promote an ancestor watch) and, if so,

Callers 1

newConfigWatcherFunction · 0.95

Calls 2

handleEventMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected