MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / run_refresh_worker_tick

Function run_refresh_worker_tick

crates/openshell-server/src/provider_refresh.rs:700–770  ·  view source on GitHub ↗
(store: &Store)

Source from the content-addressed store, hash-verified

698}
699
700async fn run_refresh_worker_tick(store: &Store) -> Result<(), Status> {
701 let now_ms = current_time_ms();
702 let states = list_all_refresh_states(store).await?;
703 let watched_count = states.len();
704 let due_count = states
705 .iter()
706 .filter(|state| state.next_refresh_at_ms <= 0 || state.next_refresh_at_ms <= now_ms)
707 .count();
708 let rotation_requested_count = states
709 .iter()
710 .filter(|state| state.status == "rotation_requested")
711 .count();
712 info!(
713 watched_count,
714 due_count, rotation_requested_count, "provider credential refresh worker sweep"
715 );
716 for state in states {
717 let strategy = ProviderCredentialRefreshStrategy::try_from(state.strategy)
718 .unwrap_or(ProviderCredentialRefreshStrategy::Unspecified);
719 let due = state.next_refresh_at_ms <= 0 || state.next_refresh_at_ms <= now_ms;
720 let rotation_requested = state.status == "rotation_requested";
721 info!(
722 provider = %state.provider_name,
723 credential_key = %state.credential_key,
724 strategy = %refresh_strategy_name(state.strategy),
725 status = %state.status,
726 expires_at_ms = state.expires_at_ms,
727 seconds_until_expiry = seconds_until_ms(now_ms, state.expires_at_ms),
728 next_refresh_at_ms = state.next_refresh_at_ms,
729 last_refresh_at_ms = state.last_refresh_at_ms,
730 seconds_until_refresh = seconds_until_ms(now_ms, state.next_refresh_at_ms),
731 due,
732 rotation_requested,
733 "provider credential refresh watch"
734 );
735 if !due && !rotation_requested {
736 continue;
737 }
738 if !is_gateway_mintable_strategy(strategy) {
739 warn!(
740 provider = %state.provider_name,
741 credential_key = %state.credential_key,
742 strategy = %refresh_strategy_name(state.strategy),
743 status = %state.status,
744 "skipping non-gateway-mintable provider credential refresh state"
745 );
746 continue;
747 }
748 info!(
749 provider = %state.provider_name,
750 credential_key = %state.credential_key,
751 strategy = %refresh_strategy_name(state.strategy),
752 status = %state.status,
753 "refreshing provider credential"
754 );
755 if let Err(err) =
756 refresh_provider_credential(store, &state.provider_name, &state.credential_key).await
757 {

Calls 5

list_all_refresh_statesFunction · 0.85
lenMethod · 0.80
current_time_msFunction · 0.50

Tested by

no test coverage detected