mirror of
https://github.com/redlib-org/redlib.git
synced 2025-04-02 04:37:35 +03:00
fix(oauth): reset rate limit earlier in refresh cycle
This commit is contained in:
parent
d045a5760a
commit
2e476dea63
2 changed files with 1 additions and 1 deletions
|
@ -320,6 +320,7 @@ pub async fn json(path: String, quarantine: bool) -> Result<Value, String> {
|
|||
let current_rate_limit = OAUTH_RATELIMIT_REMAINING.load(Ordering::Relaxed);
|
||||
if current_rate_limit < 10 {
|
||||
warn!("Rate limit {current_rate_limit} is low. Spawning force_refresh_token()");
|
||||
OAUTH_RATELIMIT_REMAINING.store(99, Ordering::Relaxed);
|
||||
tokio::spawn(force_refresh_token());
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,6 @@ pub async fn token_daemon() {
|
|||
pub async fn force_refresh_token() {
|
||||
trace!("Rolling over refresh token. Current rate limit: {}", OAUTH_RATELIMIT_REMAINING.load(Ordering::Relaxed));
|
||||
OAUTH_CLIENT.write().await.refresh().await;
|
||||
OAUTH_RATELIMIT_REMAINING.store(99, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue