|
@@ -63,7 +63,7 @@ pub struct FutureConnect {
|
|
|
|
|
|
impl FutureConnect {
|
|
|
/// Creates a new instance
|
|
|
- pub fn new(config: PgConfig, timeout: Duration, still_valid: Arc<AtomicBool>) -> Self {
|
|
|
+ pub fn new(config: PgConfig, timeout: Duration, stale: Arc<AtomicBool>) -> Self {
|
|
|
let failed = Arc::new(Mutex::new(None));
|
|
|
let result = Arc::new(OnceLock::new());
|
|
|
let notify = Arc::new(Notify::new());
|
|
@@ -79,7 +79,7 @@ impl FutureConnect {
|
|
|
Err(err) => {
|
|
|
*error_clone.lock().await =
|
|
|
Some(cdk_common::database::Error::Database(Box::new(err)));
|
|
|
- still_valid.store(false, std::sync::atomic::Ordering::Release);
|
|
|
+ stale.store(true, std::sync::atomic::Ordering::Release);
|
|
|
notify_clone.notify_waiters();
|
|
|
return;
|
|
|
}
|
|
@@ -87,7 +87,7 @@ impl FutureConnect {
|
|
|
|
|
|
tokio::spawn(async move {
|
|
|
let _ = connection.await;
|
|
|
- still_valid.store(false, std::sync::atomic::Ordering::Release);
|
|
|
+ stale.store(true, std::sync::atomic::Ordering::Release);
|
|
|
});
|
|
|
|
|
|
let _ = result_clone.set(client);
|
|
@@ -99,7 +99,7 @@ impl FutureConnect {
|
|
|
Err(err) => {
|
|
|
*error_clone.lock().await =
|
|
|
Some(cdk_common::database::Error::Database(Box::new(err)));
|
|
|
- still_valid.store(false, std::sync::atomic::Ordering::Release);
|
|
|
+ stale.store(true, std::sync::atomic::Ordering::Release);
|
|
|
notify_clone.notify_waiters();
|
|
|
return;
|
|
|
}
|
|
@@ -107,7 +107,7 @@ impl FutureConnect {
|
|
|
|
|
|
tokio::spawn(async move {
|
|
|
let _ = connection.await;
|
|
|
- still_valid.store(false, std::sync::atomic::Ordering::Release);
|
|
|
+ stale.store(true, std::sync::atomic::Ordering::Release);
|
|
|
});
|
|
|
|
|
|
let _ = result_clone.set(client);
|
|
@@ -161,10 +161,10 @@ impl ResourceManager for PgConnectionPool {
|
|
|
|
|
|
fn new_resource(
|
|
|
config: &Self::Config,
|
|
|
- still_valid: Arc<AtomicBool>,
|
|
|
+ stale: Arc<AtomicBool>,
|
|
|
timeout: Duration,
|
|
|
) -> Result<Self::Resource, cdk_sql_common::pool::Error<Self::Error>> {
|
|
|
- Ok(FutureConnect::new(config.to_owned(), timeout, still_valid))
|
|
|
+ Ok(FutureConnect::new(config.to_owned(), timeout, stale))
|
|
|
}
|
|
|
}
|
|
|
|