chore: update client api log

This commit is contained in:
nathan 2024-09-04 22:01:31 +08:00
parent 366aa03a0e
commit 886376e8bd
1 changed files with 7 additions and 2 deletions

View File

@ -30,7 +30,7 @@ use std::task::{Context, Poll};
use std::time::Duration;
use tokio_retry::strategy::{ExponentialBackoff, FixedInterval};
use tokio_retry::{Condition, RetryIf};
use tracing::{event, info, instrument, trace};
use tracing::{debug, event, info, instrument, trace};
pub use infra::file_util::ChunkedBytes;
use shared_entity::dto::ai_dto::CompleteTextParams;
@ -243,13 +243,18 @@ impl Client {
let _ = tx.send(result.clone());
}
self.is_refreshing_token.store(false, Ordering::SeqCst);
} else {
debug!("refresh token is already in progress");
}
// Wait for the result of the refresh token request.
match tokio::time::timeout(Duration::from_secs(60), rx).await {
Ok(Ok(result)) => result,
Ok(Err(err)) => Err(AppError::Internal(anyhow!("refresh token error: {}", err)).into()),
Err(_) => Err(AppError::RequestTimeout("refresh token timeout".to_string()).into()),
Err(_) => {
self.is_refreshing_token.store(false, Ordering::SeqCst);
Err(AppError::RequestTimeout("refresh token timeout".to_string()).into())
},
}
}