Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
// Path to the file or directory.
Name string
// File operation that triggered the event.
//
// This is a bitmask and some systems may send multiple operations at once.
// Use the Event.Has() method instead of comparing with ==.
Op Op
}
Event closely resembles what fsnotify.Event provided
type Op ¶ added in v1.16.11
type Op uint
Op describes a set of file operations.
type Option ¶ added in v1.16.11
type Option func(*Watcher)
Option to configure the Watcher
func WithInterval ¶ added in v1.16.11
WithInterval sets the interval at which the Watcher checks for changes
type Watcher ¶
type Watcher struct {
// Events is used to signal changes to any of the tracked files. It is
// guaranteed that Event.Name will always match one of the file paths
// passed in trackedFiles to the constructor. This channel is unbuffered
// and must be read by the consumer to avoid deadlocks.
Events chan Event
// Errors reports any errors which may occur while watching. This channel
// is unbuffered and must be read by the consumer to avoid deadlocks.
Errors chan error
// contains filtered or unexported fields
}
Watcher implements a file polling mechanism which can track non-existing files and emit creation events for them. All files which are supposed to be tracked need to passed to the New constructor.
When a directory is passed in as a tracked file, the watcher will watch all the files inside that directory, including recursion into any subdirectories.
One of the primary use cases for the watcher is tracking kubernetes projected secrets which create a maze of symlinks. It is safe to watch symlink targets as they are properly resolved, even in the case of multiple symlinks chained together. Only the content of the final destination is considered when issuing Write events.