watcher

package
v6.9.4-2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

clients.go implements watcher client lifecycle logic and persistence helpers. It reloads clients, handles incremental auth file changes, and persists updates when supported.

config_reload.go implements debounced configuration hot reload. It detects material changes and reloads clients when the config changes.

dispatcher.go implements auth update dispatching and queue management. It batches, deduplicates, and delivers auth updates to registered consumers.

events.go implements fsnotify event handling for config and auth file changes. It normalizes paths, debounces noisy events, and triggers reload/update logic.

Package watcher watches config/auth files and triggers hot reloads. It supports cross-platform fsnotify event handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAPIKeyClients

func BuildAPIKeyClients(cfg *config.Config) (int, int, int, int, int)

Types

type AuthUpdate

type AuthUpdate struct {
	Action AuthUpdateAction
	ID     string
	Auth   *coreauth.Auth
}

AuthUpdate describes an incremental change to auth configuration.

type AuthUpdateAction

type AuthUpdateAction string

AuthUpdateAction represents the type of change detected in auth sources.

const (
	AuthUpdateActionAdd    AuthUpdateAction = "add"
	AuthUpdateActionModify AuthUpdateAction = "modify"
	AuthUpdateActionDelete AuthUpdateAction = "delete"
)

type Watcher

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

Watcher manages file watching for configuration and authentication files

func NewWatcher

func NewWatcher(configPath, authDir string, reloadCallback func(*config.Config)) (*Watcher, error)

NewWatcher creates a new file watcher instance

func (*Watcher) DispatchRuntimeAuthUpdate added in v6.5.28

func (w *Watcher) DispatchRuntimeAuthUpdate(update AuthUpdate) bool

DispatchRuntimeAuthUpdate allows external runtime providers (e.g., websocket-driven auths) to push auth updates through the same queue used by file/config watchers. Returns true if the update was enqueued; false if no queue is configured.

func (*Watcher) NotifyTokenRefreshed

func (w *Watcher) NotifyTokenRefreshed(tokenID, accessToken, refreshToken, expiresAt string)

NotifyTokenRefreshed 处理后台刷新器的 token 更新通知 当后台刷新器成功刷新 token 后调用此方法,更新内存中的 Auth 对象 tokenID: token 文件名(如 kiro-xxx.json) accessToken: 新的 access token refreshToken: 新的 refresh token expiresAt: 新的过期时间

func (*Watcher) SetAuthUpdateQueue

func (w *Watcher) SetAuthUpdateQueue(queue chan<- AuthUpdate)

SetAuthUpdateQueue sets the queue used to emit auth updates.

func (*Watcher) SetConfig

func (w *Watcher) SetConfig(cfg *config.Config)

SetConfig updates the current configuration

func (*Watcher) SnapshotCoreAuths

func (w *Watcher) SnapshotCoreAuths() []*coreauth.Auth

SnapshotCoreAuths converts current clients snapshot into core auth entries.

func (*Watcher) Start

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

Start begins watching the configuration file and authentication directory

func (*Watcher) Stop

func (w *Watcher) Stop() error

Stop stops the file watcher

Directories

Path Synopsis
auth_diff.go computes human-readable diffs for auth file field changes.
auth_diff.go computes human-readable diffs for auth file field changes.
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