Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FSWatcher ¶ added in v1.44.0
type FSWatcher struct {
// contains filtered or unexported fields
}
func New ¶ added in v1.44.0
FSWatcher waits for notifications of changes in the watched directories and attempts to reload all files that changed.
Write and Rename events indicate that some files might have changed and reload might be necessary. Remove event indicates that the file was deleted and we should write a warn to log.
Reasoning:
Write event is sent if the file content is rewritten.
Usually files are not rewritten, but they are updated by swapping them with new ones by calling Rename. That avoids files being read while they are not yet completely written but it also means that inotify on file level will not work: watch is invalidated when the old file is deleted.
If reading from Kubernetes Secret volumes the target files are symbolic links to files in a different directory. That directory is swapped with a new one, while the symbolic links remain the same. This guarantees atomic swap for all files at once, but it also means any Rename event in the directory might indicate that the files were replaced, even if event.Name is not any of the files we are monitoring. We check the hashes of the files to detect if they were really changed.