Documentation
¶
Overview ¶
Package watcher provides file system watching with debouncing for the tracking database.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config holds watcher configuration options.
func DefaultConfig ¶
DefaultConfig returns sensible defaults for the watcher.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher monitors the tracking database for changes and publishes events via broker.
func (*Watcher) Broker ¶
func (w *Watcher) Broker() *pubsub.Broker[WatcherEvent]
Broker returns the pub/sub broker for subscribing to watcher events. The broker is created in New(), so it is always valid even before Start() is called.
func (*Watcher) Start ¶
Start begins watching the database directory. Subscribe to watcher events using Broker().Subscribe(ctx) instead of the old channel return.
func (*Watcher) Stop ¶
Stop terminates the watcher and releases resources. CRITICAL SHUTDOWN SEQUENCE: broker.Close() must be called BEFORE fsWatcher.Close(). This ensures subscribers receive clean channel close notifications before the underlying fsnotify watcher is destroyed. Reversing this order could leave subscribers hanging.
type WatcherEvent ¶
type WatcherEvent struct {
Type WatcherEventType
Error error // Non-nil for WatcherError events
}
WatcherEvent represents an event from the database watcher.
type WatcherEventType ¶
type WatcherEventType string
WatcherEventType identifies the kind of watcher event.
const ( // DBChanged is emitted when the database file changes (after debounce). DBChanged WatcherEventType = "db_changed" // WatcherError is emitted when the watcher encounters an error (immediate, not debounced). WatcherError WatcherEventType = "error" )