Skip to main content

run_config_reload_supervisor

Function run_config_reload_supervisor 

Source
pub async fn run_config_reload_supervisor<N, R, RFut, F, Fut>(
    notifier: Arc<N>,
    config: ConfigReloadWorkerConfig,
    shutdown: CancellationToken,
    reconcile: R,
    reload: F,
) -> Result<()>
where N: ConfigChangeNotifier + ?Sized, R: FnMut() -> RFut, RFut: Future<Output = Result<()>>, F: FnMut(ConfigReloadMessage) -> Fut, Fut: Future<Output = Result<()>>,
Expand description

Runs a reconnecting reload subscription with authoritative reconciliation.

reconcile runs after every successful subscription, including the initial connection. This closes the race between the product’s startup snapshot load and the moment pub/sub begins receiving notifications. After a disconnect it also repairs any changes missed while the transient transport was unavailable.

A disconnect is any of: subscribe failure, transport stream error or ending, and local broadcast lag (the receiver fell behind and events were dropped). Each one is observed, waited out with bounded exponential backoff (250 ms initial, 30 s cap, jittered; the failure counter resets after a subscription stays stable for 30 s), then followed by a fresh subscription and reconcile. Failed reloads or reconciliations schedule one authoritative reconcile retry with the same delay bounds, independent of transport health. Only successful reconciliation clears this pending work; a later key-specific reload cannot prove that all previously missed changes and derived caches are current. Shutdown cancels both retry waits and in-flight callbacks. Callbacks must be safe to drop and repeat after partially completed work. The loop only returns when shutdown is cancelled.

§Errors

Returns [ConfigError] when publishing, subscription, reconciliation, or reload handling fails.