watcher

package
v1.0.44 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package watcher watches the config file and auth directory for changes and triggers hot reload callbacks.

This is a simplified fsnotify-based watcher aligned with CLIProxyAPI's hot reload behavior: - Watch the parent directory of the config file (robust against atomic save/rename). - Watch the auth-dir directory for *.json changes (add/modify/remove/rename). - Debounce noisy event bursts and reload based on current filesystem state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callbacks

type Callbacks struct {
	// OnConfigReload is invoked after the config file is reloaded successfully.
	OnConfigReload func(ctx context.Context, cfg *config.Config)
	// OnConfigYAMLChange is invoked when the config file content changes (raw YAML bytes).
	// It is called even if the updated config cannot be parsed successfully.
	OnConfigYAMLChange func(ctx context.Context, data []byte)
	// OnAuthChange is invoked when auth-dir content changes and should be reloaded.
	OnAuthChange func(ctx context.Context)
}

type Watcher

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

Watcher watches config.yaml and auth-dir for changes and triggers callbacks.

func NewWatcher

func NewWatcher(configPath string, authDir string, cb Callbacks) (*Watcher, error)

NewWatcher creates a new watcher.

func (*Watcher) Start

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

Start starts the process.

func (*Watcher) Stop

func (w *Watcher) Stop() error

Stop stops the process.

Directories

Path Synopsis
Package synthesizer provides auth synthesis strategies for the watcher package.
Package synthesizer provides auth synthesis strategies for the watcher package.

Jump to

Keyboard shortcuts

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