Documentation
¶
Index ¶
- Variables
- type FileWatcher
- func (fw *FileWatcher) Close() error
- func (fw *FileWatcher) Poll(path string, callback func(string), interval time.Duration) error
- func (fw *FileWatcher) Start()
- func (fw *FileWatcher) Unwatch(path string) error
- func (fw *FileWatcher) Watch(path string, callback func(string), debounceDuration time.Duration) error
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyRegistered = errors.New("path is already registered; call Unwatch before registering it again")
ErrAlreadyRegistered reports that a path already has a Watch or Poll registration. Call Unwatch before registering the same normalized path again.
var ErrClosed = errors.New("file watcher is closed")
ErrClosed reports that Watch or Poll was called after the watcher closed.
Functions ¶
This section is empty.
Types ¶
type FileWatcher ¶
type FileWatcher struct {
// contains filtered or unexported fields
}
FileWatcher watches database files for changes.
func NewFileWatcher ¶
func NewFileWatcher() (*FileWatcher, error)
NewFileWatcher creates a new file watcher.
func (*FileWatcher) Close ¶
func (fw *FileWatcher) Close() error
Close cancels future watcher work, pending debounce timers, and pollers. Repeated and concurrent calls return the same result. A callback that was already claimed may finish after Close returns, which keeps Close safe when it is called synchronously from inside that callback.
func (*FileWatcher) Poll ¶
Poll checks a local file or URL on an interval and invokes callback after content changes. It is primarily used for remote database sources.
func (*FileWatcher) Start ¶
func (fw *FileWatcher) Start()
Start begins watching for local file changes.
func (*FileWatcher) Unwatch ¶
func (fw *FileWatcher) Unwatch(path string) error
Unwatch prevents future callbacks from being claimed for path and cancels its poller or pending debounce timer. A callback already claimed before the removal may still start or finish after Unwatch returns. This non-blocking teardown makes it safe for a callback to unwatch itself.