configwatch

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package configwatch is an internal helper that fires a callback whenever the on-disk YAML config changes. Used by cmd/nexus to drive engine.ReloadConfig from fsnotify edits when operators opt in via engine.config_watch.enabled.

The watcher debounces bursts of fsnotify events on the same file because editors commonly fire two or three Write events when saving. Reading a half-written YAML through the validator would surface a confusing schema error, so we wait for the burst to settle before invoking the callback. The default debounce (1s) is well above the typical Vim/VSCode save storm but short enough that the operator perceives the reload as instant.

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 monitors a single YAML file and invokes onChange after each debounced edit. Methods are goroutine-safe.

func New

func New(path string, debounce time.Duration, logger *slog.Logger, onChange func()) (*Watcher, error)

New constructs a Watcher rooted at path with the given debounce and a callback to invoke after debounced changes. fsnotify watches the parent directory rather than the file itself because editors that swap on save (Vim's :w default) replace the file's inode — a watcher on the original path would not see the swap.

func (*Watcher) Close

func (w *Watcher) Close() error

Close stops the watcher. Safe to call multiple times.

Jump to

Keyboard shortcuts

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