Documentation
¶
Overview ¶
Package watcher monitors a directory tree for filesystem changes and delivers batched, debounced events to callers.
Watcher is the interface; New selects an implementation based on config.Config.WatchMode: "fsnotify" for kernel-level notifications, "poll" for periodic directory scanning, or "auto" which tries fsnotify and falls back to polling. Event carries the changed path and Op type.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsWatchLimitError ¶
IsWatchLimitError reports whether err is a OS-level watch-limit error. On Linux this is ENOSPC (inotify watch table full); on macOS it is EMFILE (per-process file descriptor limit) or ENFILE (system-wide limit).
Types ¶
type Watcher ¶
type Watcher interface {
// Watch returns a channel of batched, debounced events.
// The channel is closed when ctx is cancelled or Close is called.
// Watch must be called exactly once per Watcher instance.
Watch(ctx context.Context) <-chan []Event
Close() error
}
Watcher monitors a directory tree for file changes. Watch must be called exactly once; calling it a second time is not safe.
func New ¶
New creates a Watcher based on cfg.WatchMode:
- "poll": polling watcher
- "fsnotify": fsnotify watcher (errors if unavailable)
- "auto" or "": attempts fsnotify; falls back to polling on error or watch limit
matchFn, when non-nil, is called to decide whether a file path should produce events. Pass nil to use the include/exclude pattern logic only. fsys is the filesystem to walk; pass w.FS() (the walker's os.Root-scoped FS) for production use to prevent symlink-escape attacks.