configwatcher

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectAutoReload added in v0.3.0

func ConnectAutoReload(w *ConfigWatcher, app modular.ReloadableApp)

ConnectAutoReload wires an already-constructed ConfigWatcher to the given modular.ReloadableApp. It replaces any previously registered OnChange callback. Prefer WithAutoReload when constructing the watcher; use this function when the watcher and the application are wired together after construction.

Example:

w := configwatcher.New(configwatcher.WithPaths("config.yaml"))
configwatcher.ConnectAutoReload(w, app)

Types

type ConfigWatcher

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

ConfigWatcher watches config files and calls OnChange when modifications are detected.

func New

func New(opts ...Option) *ConfigWatcher

func (*ConfigWatcher) Init

func (w *ConfigWatcher) Init(app modular.Application) error

Init satisfies the modular.Module interface. Captures the application logger if one was not provided via WithLogger.

func (*ConfigWatcher) Name

func (w *ConfigWatcher) Name() string

func (*ConfigWatcher) Start

func (w *ConfigWatcher) Start(ctx context.Context) error

func (*ConfigWatcher) Stop

func (w *ConfigWatcher) Stop(_ context.Context) error

type Option

type Option func(*ConfigWatcher)

Option configures a ConfigWatcher.

func WithAutoReload added in v0.3.0

func WithAutoReload(app modular.ReloadableApp) Option

WithAutoReload returns an Option that wires the ConfigWatcher to the given modular.ReloadableApp so that every detected file-change triggers a configuration reload via app.RequestReload.

The reload is fired with a ReloadFileChange trigger and an empty ConfigDiff. The orchestrator will still call CanReload / Reload on all registered Reloadable modules so they can re-read their configuration.

Example:

w := configwatcher.New(
    configwatcher.WithPaths("config.yaml"),
    configwatcher.WithAutoReload(app),
)

func WithDebounce

func WithDebounce(d time.Duration) Option

func WithLogger

func WithLogger(l modular.Logger) Option

func WithOnChange

func WithOnChange(fn func(paths []string)) Option

func WithPaths

func WithPaths(paths ...string) Option

Jump to

Keyboard shortcuts

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