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
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),
)