pub struct RefreshFailureCache(/* private fields */);Expand description
Per-(upstream_name, subject) “is this credential known-broken right now”
cache.
Without this, a dead refresh token (revoked, expired, invalid_grant, …)
gets retried against the authorization server on every single request
forever — TokenRefreshState::refresh_due() is purely time-based and has
no memory of prior outcomes. That wastes latency on every real request
touching the upstream, and can itself contribute to the authorization
server rate-limiting or flagging the client_id, which is especially bad
when multiple upstreams share one client_id (see labby-auth::upstream
module docs).
Implementations§
Source§impl RefreshFailureCache
impl RefreshFailureCache
pub fn new() -> Self
Sourcepub fn record_failure(&self, upstream_name: &str, subject: &str)
pub fn record_failure(&self, upstream_name: &str, subject: &str)
Record that a refresh just failed for (upstream_name, subject).
Sourcepub fn clear(&self, upstream_name: &str, subject: &str)
pub fn clear(&self, upstream_name: &str, subject: &str)
Clear any recorded failure for (upstream_name, subject) — call this on
any successful refresh, a fresh authorization completing, or explicit
credential clearing, so a fix is picked up immediately instead of
waiting out the cooldown.
Sourcepub fn recently_failed(&self, upstream_name: &str, subject: &str) -> bool
pub fn recently_failed(&self, upstream_name: &str, subject: &str) -> bool
Whether (upstream_name, subject) failed recently enough that a live
retry should be skipped.