reload

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package reload provides configuration hot reload functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatValidationErrors

func FormatValidationErrors(errors []ValidationError) string

FormatValidationErrors formats validation errors into a readable string

Types

type ConfigDiff

type ConfigDiff struct {
	MonitorsAdded      []types.MonitorConfig
	MonitorsRemoved    []types.MonitorConfig
	MonitorsModified   []MonitorChange
	ExportersChanged   bool
	RemediationChanged bool
}

ConfigDiff represents the differences between two configurations.

func ComputeConfigDiff

func ComputeConfigDiff(oldConfig, newConfig *types.NodeDoctorConfig) *ConfigDiff

ComputeConfigDiff calculates the differences between old and new configurations.

func (*ConfigDiff) HasChanges

func (d *ConfigDiff) HasChanges() bool

HasChanges returns true if there are any configuration changes.

type ConfigValidator

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

ConfigValidator validates NodeDoctor configurations

func NewConfigValidator

func NewConfigValidator() *ConfigValidator

NewConfigValidator creates a new configuration validator with default limits

func NewConfigValidatorWithLimits

func NewConfigValidatorWithLimits(
	maxMonitors,
	maxRemediatorsPerMonitor,
	maxWebhooksPerExporter,
	maxDependenciesPerMonitor int,
) *ConfigValidator

NewConfigValidatorWithLimits creates a new configuration validator with custom limits

func (*ConfigValidator) Validate

Validate validates a NodeDoctor configuration

type ConfigWatcher

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

ConfigWatcher watches a configuration file for changes and emits reload events.

func NewConfigWatcher

func NewConfigWatcher(configPath string, debounceInterval time.Duration) (*ConfigWatcher, error)

NewConfigWatcher creates a new configuration file watcher.

func (*ConfigWatcher) Start

func (cw *ConfigWatcher) Start(ctx context.Context) (<-chan struct{}, error)

Start begins watching the configuration file for changes. Returns a channel that receives events when the config file changes.

func (*ConfigWatcher) Stop

func (cw *ConfigWatcher) Stop()

Stop stops watching the configuration file.

type EventEmitter

type EventEmitter func(severity types.EventSeverity, reason, message string)

EventEmitter emits reload status events.

type MonitorChange

type MonitorChange struct {
	Old types.MonitorConfig
	New types.MonitorConfig
}

MonitorChange represents a modification to a monitor configuration.

type ReloadCallback

type ReloadCallback func(ctx context.Context, newConfig *types.NodeDoctorConfig, diff *ConfigDiff) error

ReloadCallback is called when a configuration reload is needed. It receives the new configuration and the diff, and should apply the changes.

type ReloadCoordinator

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

ReloadCoordinator orchestrates configuration reload operations.

func NewReloadCoordinator

func NewReloadCoordinator(
	configPath string,
	initialConfig *types.NodeDoctorConfig,
	reloadCallback ReloadCallback,
	eventEmitter EventEmitter,
) *ReloadCoordinator

NewReloadCoordinator creates a new reload coordinator.

func NewReloadCoordinatorWithValidator

func NewReloadCoordinatorWithValidator(
	configPath string,
	initialConfig *types.NodeDoctorConfig,
	reloadCallback ReloadCallback,
	eventEmitter EventEmitter,
	validator *ConfigValidator,
) *ReloadCoordinator

NewReloadCoordinatorWithValidator creates a new reload coordinator with a custom validator.

func (*ReloadCoordinator) GetCurrentConfig

func (rc *ReloadCoordinator) GetCurrentConfig() *types.NodeDoctorConfig

GetCurrentConfig returns the current active configuration (thread-safe).

func (*ReloadCoordinator) GetValidator

func (rc *ReloadCoordinator) GetValidator() *ConfigValidator

GetValidator returns the configuration validator used by this coordinator.

func (*ReloadCoordinator) SetValidator

func (rc *ReloadCoordinator) SetValidator(validator *ConfigValidator)

SetValidator sets a new configuration validator. This is useful for testing or when different validation rules are needed.

func (*ReloadCoordinator) TriggerReload

func (rc *ReloadCoordinator) TriggerReload(ctx context.Context) error

TriggerReload attempts to reload the configuration from disk. This method is safe to call concurrently; only one reload happens at a time.

type ValidationError

type ValidationError struct {
	Field   string // Field path (e.g., "monitors[0].name")
	Message string // Human-readable error message
}

ValidationError represents a configuration validation error

type ValidationResult

type ValidationResult struct {
	Valid  bool
	Errors []ValidationError
}

ValidationResult contains the result of configuration validation

Jump to

Keyboard shortcuts

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