run is the watcher loop. It exits when the underlying fsnotify.Watcher closes its channels or Close is called.
()
| 213 | // run is the watcher loop. It exits when the underlying |
| 214 | // fsnotify.Watcher closes its channels or Close is called. |
| 215 | func (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, |
no test coverage detected