filewatch

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package filewatch coalesces filesystem notifications for mounted configuration files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher watches the parent directories of a set of files. Watching directories, rather than resolved file targets, preserves notifications when Kubernetes swaps a projected volume's ..data symlink.

func New

func New(paths []string, debounce, maxDebounce time.Duration, onChange func(), onError func(error)) (*Watcher, error)

New starts a watcher. Events are delayed until debounce has elapsed without a new event, but a continuous burst is delivered no later than maxDebounce after its first event -- with one exception: when the maxDebounce cap is what ends a burst and nothing is yet queued, the watcher grants one further debounce-length grace so an fsnotify event still in flight from the kernel to the delivery goroutine can merge into the same burst instead of starting a new one (issue #885). The effective worst-case delivery bound is therefore maxDebounce+debounce, granted at most once per burst. onError receives watcher errors; it must not assume an error is fatal. Paths are used only to select and deduplicate their parent directories.

func (*Watcher) Close

func (w *Watcher) Close() error

Close stops the watcher, cancels any pending debounce, and joins its goroutine. It is safe to call repeatedly.

Jump to

Keyboard shortcuts

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