MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / spawn_refresh_task

Function spawn_refresh_task

nodedb/src/control/security/jwks/fetch.rs:217–236  ·  view source on GitHub ↗

Start the periodic JWKS refresh task. Spawns a Tokio task that refreshes JWKS keys for all providers at the configured interval. Runs on the Control Plane.

(
    providers: Vec<(String, String)>, // (name, jwks_url) pairs
    cache: std::sync::Arc<JwksCache>,
    refresh_interval_secs: u64,
    policy: std::sync::Arc<JwksPolicy>,
)

Source from the content-addressed store, hash-verified

215/// Spawns a Tokio task that refreshes JWKS keys for all providers
216/// at the configured interval. Runs on the Control Plane.
217pub fn spawn_refresh_task(
218 providers: Vec<(String, String)>, // (name, jwks_url) pairs
219 cache: std::sync::Arc<JwksCache>,
220 refresh_interval_secs: u64,
221 policy: std::sync::Arc<JwksPolicy>,
222) -> tokio::task::JoinHandle<()> {
223 tokio::spawn(async move {
224 let mut interval =
225 tokio::time::interval(std::time::Duration::from_secs(refresh_interval_secs));
226 // First tick fires immediately — skip it since we fetch on startup.
227 interval.tick().await;
228
229 loop {
230 interval.tick().await;
231 for (name, url) in &providers {
232 fetch_and_cache(name, url, &cache, &policy).await;
233 }
234 }
235 })
236}

Callers 1

initMethod · 0.85

Calls 3

fetch_and_cacheFunction · 0.85
spawnFunction · 0.50
tickMethod · 0.45

Tested by

no test coverage detected