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>,
)
| 215 | /// Spawns a Tokio task that refreshes JWKS keys for all providers |
| 216 | /// at the configured interval. Runs on the Control Plane. |
| 217 | pub 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 | } |
no test coverage detected