pub struct ProviderCatalogCache {
pub entries: BTreeMap<String, CachedProviderCatalog>,
}Expand description
A secret-free store of cached provider catalogs, keyed by provider + base-URL fingerprint.
Scoping rule (#3385): the SAME provider on DIFFERENT base URLs must not share rows, and DIFFERENT providers on the same base URL must not share rows.
Fields§
§entries: BTreeMap<String, CachedProviderCatalog>Entries keyed by ProviderCatalogCache::cache_key.
Implementations§
Source§impl ProviderCatalogCache
impl ProviderCatalogCache
Sourcepub fn cache_key(provider: &str, base_url_fingerprint: &str) -> String
pub fn cache_key(provider: &str, base_url_fingerprint: &str) -> String
Compute the composite cache key for a provider + base-URL fingerprint.
Sourcepub fn get(
&self,
provider: &str,
base_url_fingerprint: &str,
) -> Option<&CachedProviderCatalog>
pub fn get( &self, provider: &str, base_url_fingerprint: &str, ) -> Option<&CachedProviderCatalog>
Look up a cached entry by provider + base-URL fingerprint.
Sourcepub fn record_success(&mut self, delta: ProviderCatalogDelta, ttl_secs: u64)
pub fn record_success(&mut self, delta: ProviderCatalogDelta, ttl_secs: u64)
Record a successful refresh, replacing any prior entry for this scope.
Offering sources are normalized to CatalogSource::Live with the
delta’s fingerprint and fetched_at, so cached rows always carry honest
provenance regardless of how the delta was assembled.
Sourcepub fn record_failure(
&mut self,
provider: &str,
base_url_fingerprint: &str,
reason: CatalogRefreshError,
)
pub fn record_failure( &mut self, provider: &str, base_url_fingerprint: &str, reason: CatalogRefreshError, )
Record a refresh failure.
Previously cached rows for this scope are preserved (so the UI can still
offer them with a visible “stale/failed” status); only the status is
updated. When no prior entry exists, an empty Failed entry is created so
the failure is observable.
Sourcepub fn status(
&self,
provider: &str,
base_url_fingerprint: &str,
now_unix: u64,
) -> CatalogStatus
pub fn status( &self, provider: &str, base_url_fingerprint: &str, now_unix: u64, ) -> CatalogStatus
The resolved status of an entry at now_unix.
A Fresh-recorded entry that has since aged past its TTL reports
Stale; Failed/Unknown are returned as stored.
Sourcepub fn fresh_offerings(
&self,
provider: &str,
base_url_fingerprint: &str,
now_unix: u64,
) -> Vec<CatalogOffering>
pub fn fresh_offerings( &self, provider: &str, base_url_fingerprint: &str, now_unix: u64, ) -> Vec<CatalogOffering>
Fresh (within-TTL) live offerings for one provider + base URL at
now_unix. Stale or failed entries contribute nothing here; callers fall
back to bundled/configured rows and surface the status separately.
Sourcepub fn all_fresh_offerings(&self, now_unix: u64) -> Vec<CatalogOffering>
pub fn all_fresh_offerings(&self, now_unix: u64) -> Vec<CatalogOffering>
All fresh live offerings across every cached provider + base URL.
Sourcepub fn all_visible_offerings(&self, _now_unix: u64) -> Vec<CatalogOffering>
pub fn all_visible_offerings(&self, _now_unix: u64) -> Vec<CatalogOffering>
Live offerings that pickers may still show: fresh rows plus stale / prior rows that survived a failed refresh (#4139).
Unlike Self::all_fresh_offerings, this keeps past-TTL and
Failed-status entries as long as they still hold offering rows. Empty
entries contribute nothing; callers fall back to the bundled snapshot.
now_unix is accepted for API symmetry with the fresh helper (age chips
live above this layer).
Trait Implementations§
Source§impl Clone for ProviderCatalogCache
impl Clone for ProviderCatalogCache
Source§fn clone(&self) -> ProviderCatalogCache
fn clone(&self) -> ProviderCatalogCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more