fswatcher

package
v1.61.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

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

func New(filepaths []string, onChange func(), logger *zap.Logger) (*FSWatcher, error)

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.

func (*FSWatcher) Close added in v1.44.0

func (w *FSWatcher) Close() error

Close closes the watcher.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL