pub struct ConfigHotReload {Show 18 fields
active_config: Arc<RwLock<AirConfiguration>>,
previous_config: Arc<RwLock<Option<AirConfiguration>>>,
last_config_hash: Arc<RwLock<Option<String>>>,
config_path: PathBuf,
watcher: Option<Arc<RwLock<RecommendedWatcher>>>,
change_sender: Sender<ConfigChangeEvent>,
reload_tx: Sender<ReloadRequest>,
change_history: Arc<RwLock<Vec<ConfigChangeRecord>>>,
last_reload: Arc<RwLock<Option<DateTime<Utc>>>>,
last_reload_duration: Arc<RwLock<Option<Duration>>>,
enabled: Arc<RwLock<bool>>,
debounce_delay: Duration,
last_change_time: Arc<RwLock<Option<Instant>>>,
stats: Arc<RwLock<ReloadStats>>,
validators: Arc<RwLock<Vec<Box<dyn ConfigValidator>>>>,
max_retries: u32,
retry_delay: Duration,
auto_rollback_enabled: Arc<RwLock<bool>>,
}Expand description
Configuration hot-reload manager with file watching and validation
Fields§
§active_config: Arc<RwLock<AirConfiguration>>Current active configuration
previous_config: Arc<RwLock<Option<AirConfiguration>>>Previous configuration for rollback
last_config_hash: Arc<RwLock<Option<String>>>Last successful configuration hash
config_path: PathBufConfiguration file path
watcher: Option<Arc<RwLock<RecommendedWatcher>>>File watcher for monitoring changes
change_sender: Sender<ConfigChangeEvent>Change notification sender for subscribers
reload_tx: Sender<ReloadRequest>Reload request channel (for signal handling and manual triggers)
change_history: Arc<RwLock<Vec<ConfigChangeRecord>>>Change history for auditing
last_reload: Arc<RwLock<Option<DateTime<Utc>>>>Last reload timestamp
last_reload_duration: Arc<RwLock<Option<Duration>>>Last reload duration
enabled: Arc<RwLock<bool>>Whether hot-reload is enabled
debounce_delay: DurationReload debounce delay to prevent rapid successive reloads
last_change_time: Arc<RwLock<Option<Instant>>>Last file change timestamp (for debouncing)
stats: Arc<RwLock<ReloadStats>>Reload statistics
validators: Arc<RwLock<Vec<Box<dyn ConfigValidator>>>>Validation callbacks
max_retries: u32Maximum retry attempts for failed reloads
retry_delay: DurationRetry delay with exponential backoff
auto_rollback_enabled: Arc<RwLock<bool>>Whether automatic rollback is enabled on validation failure
Implementations§
Source§impl ConfigHotReload
impl ConfigHotReload
Sourcepub async fn New(
config_path: PathBuf,
initial_config: AirConfiguration,
) -> Result<Self>
pub async fn New( config_path: PathBuf, initial_config: AirConfiguration, ) -> Result<Self>
Sourcefn DefaultValidators() -> Vec<Box<dyn ConfigValidator>>
fn DefaultValidators() -> Vec<Box<dyn ConfigValidator>>
Get the default set of validators
Sourcepub async fn EnableFileWatching(&mut self) -> Result<()>
pub async fn EnableFileWatching(&mut self) -> Result<()>
Enable file watching for configuration changes
Sourcepub async fn DisableFileWatching(&mut self) -> Result<()>
pub async fn DisableFileWatching(&mut self) -> Result<()>
Disable file watching
Sourcefn StartReloadProcessor(&self, reload_rx: Receiver<ReloadRequest>)
fn StartReloadProcessor(&self, reload_rx: Receiver<ReloadRequest>)
Start the reload request processor
Sourcepub async fn Reload(&self) -> Result<()>
pub async fn Reload(&self) -> Result<()>
Reload configuration from file with retry logic and rollback support
Sourceasync fn AttemptReload(&self) -> Result<()>
async fn AttemptReload(&self) -> Result<()>
Attempt to reload configuration (single attempt)
Sourcepub async fn ReloadAndValidate(&self) -> Result<()>
pub async fn ReloadAndValidate(&self) -> Result<()>
Reload and validate configuration (alias for Reload)
Sourcepub async fn TriggerReload(&self) -> Result<()>
pub async fn TriggerReload(&self) -> Result<()>
Trigger a manual reload
Sourceasync fn ValidateConfig(&self, config: &AirConfiguration) -> Result<()>
async fn ValidateConfig(&self, config: &AirConfiguration) -> Result<()>
Validate configuration using all registered validators
Sourcepub async fn RegisterValidator(&self, validator: Box<dyn ConfigValidator>)
pub async fn RegisterValidator(&self, validator: Box<dyn ConfigValidator>)
Register a custom validator
Sourcepub async fn GetConfig(&self) -> AirConfiguration
pub async fn GetConfig(&self) -> AirConfiguration
Get current configuration
Sourcepub async fn GetConfigRef(&self) -> RwLockReadGuard<'_, AirConfiguration>
pub async fn GetConfigRef(&self) -> RwLockReadGuard<'_, AirConfiguration>
Get current configuration (read-only, non-copying)
Sourcepub async fn SetValue(&self, path: &str, value: &str) -> Result<()>
pub async fn SetValue(&self, path: &str, value: &str) -> Result<()>
Set configuration value by path (e.g., “grpc.bind_address”)
Sourcefn SetConfigValue(
config: &mut AirConfiguration,
path: &str,
value: &str,
) -> Result<()>
fn SetConfigValue( config: &mut AirConfiguration, path: &str, value: &str, ) -> Result<()>
Set a nested configuration value
Sourcefn ComputeChanges(
&self,
old: &AirConfiguration,
new: &AirConfiguration,
) -> Vec<ConfigChange>
fn ComputeChanges( &self, old: &AirConfiguration, new: &AirConfiguration, ) -> Vec<ConfigChange>
Compute configuration changes
Sourcefn DiffJson(
prefix: &str,
old: &Value,
new: &Value,
changes: &mut Vec<ConfigChange>,
)
fn DiffJson( prefix: &str, old: &Value, new: &Value, changes: &mut Vec<ConfigChange>, )
Recursively diff JSON objects
Sourcepub async fn GetChangeHistory(
&self,
limit: Option<usize>,
) -> Vec<ConfigChangeRecord>
pub async fn GetChangeHistory( &self, limit: Option<usize>, ) -> Vec<ConfigChangeRecord>
Get change history
Sourcepub async fn GetLastReload(&self) -> Option<DateTime<Utc>>
pub async fn GetLastReload(&self) -> Option<DateTime<Utc>>
Get last reload timestamp
Sourcepub async fn GetLastReloadDuration(&self) -> Option<Duration>
pub async fn GetLastReloadDuration(&self) -> Option<Duration>
Get last reload duration
Sourcepub async fn GetStats(&self) -> ReloadStats
pub async fn GetStats(&self) -> ReloadStats
Get reload statistics
Sourcepub async fn SetAutoRollback(&self, enabled: bool)
pub async fn SetAutoRollback(&self, enabled: bool)
Set whether auto-rollback is enabled
Sourcepub fn SubscribeChanges(&self) -> Receiver<ConfigChangeEvent>
pub fn SubscribeChanges(&self) -> Receiver<ConfigChangeEvent>
Get configuration change event receiver
This can be used to subscribe to configuration change notifications
Sourcepub fn GetConfigPath(&self) -> &Path
pub fn GetConfigPath(&self) -> &Path
Get configuration path
Sourcepub async fn SetDebounceDelay(&self, delay: Duration)
pub async fn SetDebounceDelay(&self, delay: Duration)
Set debounce delay
Auto Trait Implementations§
impl Freeze for ConfigHotReload
impl !RefUnwindSafe for ConfigHotReload
impl Send for ConfigHotReload
impl Sync for ConfigHotReload
impl Unpin for ConfigHotReload
impl !UnwindSafe for ConfigHotReload
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].