Expand description
Per-provider OAuth refresh coalesce.
refresh_if_expired looks up the stored OAuth credential for a provider
and, if it is expired (or within 60 s of expiry), refreshes it via
provider_oauth::refresh_grant. Concurrent callers for the same
provider share a single in-flight refresh — once one finishes, all
subsequent callers see the freshly stored token without making a
second network request.
§Storage injection
The public entry point reads from the process-wide shared_auth_storage
singleton. The inner refresh_if_expired_with_storage helper accepts an
explicit &Arc<AuthStorage> so tests can drive an in-memory storage
without touching the real auth.json. This mirrors the controller’s
pre-flight API-alignment note: callers must NOT assume a method like
auth.get_api_key_full exists — we read the full credential set via
auth.get_all() and pattern-match the OAuth variant.
Enums§
Functions§
- invalidate_
coalesce - Drop the coalesce cell for
providerso the next call torefresh_if_expiredis forced to do a fresh refresh. Intended for tests and for error-recovery paths that want to invalidate a failed cell so a retry actually retries instead of returning the cachedRefreshError::Failed. - refresh_
if_ expired - Refresh the stored OAuth credential for
providerif it is expired or within 60 seconds of expiry. Concurrent calls coalesce on a per-providerOnceCellso the network round-trip runs at most once per cycle. - refresh_
if_ expired_ with_ storage - Inner helper: refresh against an explicit
AuthStorage.