pub(crate) async fn run_central_kv_sync(
sync_cfg: CentralKvSyncConfig,
local_store: Store,
local_key: String,
shutdown_rx: Receiver<bool>,
)Expand description
Watches central NATS KV and mirrors valid updates into the local bucket.
Each pass connects, opens the central bucket, mirrors the current value once,
and then watches the key. Only Put operations are mirrored; deletes and purges
are logged and ignored, and invalid values are skipped. After a connection,
bucket, or watch failure, or when the watch ends, the task waits 5 s and starts a
new pass. It returns when the shutdown channel becomes true.
Writes to local KV are then picked up by watch_kv_config like any other
update.
ยงArguments
sync_cfg- Central connection and key details.local_store- Local KV bucket to write into.local_key- Local configuration key.shutdown_rx- Shutdown flag shared with the rest of the process.