mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-19 08:39:44 +00:00
fix: compilation error, warnings
This commit is contained in:
@@ -289,13 +289,13 @@ pub trait DatabaseError: 'static + Send + Sync + StdError {
|
||||
/// For example, the Postgres driver overrides this to return `true` for the following error codes:
|
||||
///
|
||||
/// * `53300 too_many_connections`: returned when the maximum connections are exceeded
|
||||
/// on the server. Assumed to be the result of a temporary overcommit
|
||||
/// (e.g. an extra application replica being spun up to replace one that is going down).
|
||||
/// on the server. Assumed to be the result of a temporary overcommit
|
||||
/// (e.g. an extra application replica being spun up to replace one that is going down).
|
||||
/// * This error being consistently logged or returned is a likely indicator of a misconfiguration;
|
||||
/// the sum of [`PoolOptions::max_connections`] for all replicas should not exceed
|
||||
/// the maximum connections allowed by the server.
|
||||
/// * `57P03 cannot_connect_now`: returned when the database server is still starting up
|
||||
/// and the tcop component is not ready to accept connections yet.
|
||||
/// and the tcop component is not ready to accept connections yet.
|
||||
fn is_retryable_connect_error(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
use crate::connection::{ConnectOptions, Connection};
|
||||
use crate::database::Database;
|
||||
use crate::pool::connection::{Floating, Live};
|
||||
use crate::pool::connection::Floating;
|
||||
use crate::pool::inner::PoolInner;
|
||||
use crate::pool::PoolConnection;
|
||||
use crate::rt::JoinHandle;
|
||||
use crate::Error;
|
||||
use ease_off::EaseOff;
|
||||
use event_listener::{Event, EventListener};
|
||||
use event_listener::Event;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
use std::ptr;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::task::{Context, Poll};
|
||||
use std::time::{Duration, Instant};
|
||||
use tracing::Instrument;
|
||||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
|
||||
use std::io;
|
||||
|
||||
@@ -74,7 +71,7 @@ use std::io;
|
||||
/// `set_connect_options` and `get_connect_options` were removed in 0.9.0 because they complicated
|
||||
/// the pool internals. They can be reimplemented by capturing a mutex, or similar, in the callback.
|
||||
///
|
||||
/// This example uses Postgres and [`tokio::sync::Mutex`] but may be adapted to any driver
|
||||
/// This example uses Postgres and [`tokio::sync::RwLock`] but may be adapted to any driver
|
||||
/// or `async-std`, respectively.
|
||||
///
|
||||
/// ```rust,no_run
|
||||
@@ -197,11 +194,11 @@ pub trait PoolConnector<DB: Database>: Send + Sync + 'static {
|
||||
///
|
||||
/// * [`io::ErrorKind::ConnectionRefused`]
|
||||
/// * Database errors for which
|
||||
/// [`is_retryable_connect_error`][crate::error::DatabaseError::is_retryable_connect_error]
|
||||
/// returns `true`.
|
||||
/// [`is_retryable_connect_error`][crate::error::DatabaseError::is_retryable_connect_error]
|
||||
/// returns `true`.
|
||||
/// * [`Error::PoolConnector`] with `retryable: true`.
|
||||
/// This error kind is not returned internally and is designed to allow this method to return
|
||||
/// arbitrary error types not otherwise supported.
|
||||
/// This error kind is not returned internally and is designed to allow this method to return
|
||||
/// arbitrary error types not otherwise supported.
|
||||
///
|
||||
/// Manual implementations of this method may also use the signature:
|
||||
/// ```rust,ignore
|
||||
@@ -363,7 +360,7 @@ impl ConnectionCounter {
|
||||
// Check that `self` can increase size first before we check the parent.
|
||||
let acquired = self.acquire_permit_self(pool).await;
|
||||
|
||||
if let Some(parent) = &pool.options.parent_pool {
|
||||
if let Some(parent) = pool.parent() {
|
||||
let (_, permit) = parent.0.counter.acquire_permit_self(&parent.0).await;
|
||||
|
||||
// consume the parent permit
|
||||
|
||||
@@ -4,8 +4,6 @@ use std::ops::{Deref, DerefMut};
|
||||
use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use crate::sync::AsyncSemaphoreReleaser;
|
||||
|
||||
use crate::connection::Connection;
|
||||
use crate::database::Database;
|
||||
use crate::error::Error;
|
||||
|
||||
@@ -91,7 +91,7 @@ impl<DB: Database> PoolInner<DB> {
|
||||
}
|
||||
}
|
||||
|
||||
fn parent(&self) -> Option<&Pool<DB>> {
|
||||
pub(super) fn parent(&self) -> Option<&Pool<DB>> {
|
||||
self.options.parent_pool.as_ref()
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ use std::future::Future;
|
||||
use std::pin::{pin, Pin};
|
||||
use std::sync::Arc;
|
||||
use std::task::{ready, Context, Poll};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use event_listener::EventListener;
|
||||
use futures_core::FusedFuture;
|
||||
@@ -628,15 +627,6 @@ impl FusedFuture for CloseEvent {
|
||||
}
|
||||
}
|
||||
|
||||
/// get the time between the deadline and now and use that as our timeout
|
||||
///
|
||||
/// returns `Error::PoolTimedOut` if the deadline is in the past
|
||||
fn deadline_as_timeout(deadline: Instant) -> Result<Duration, Error> {
|
||||
deadline
|
||||
.checked_duration_since(Instant::now())
|
||||
.ok_or(Error::PoolTimedOut)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(dead_code)]
|
||||
fn assert_pool_traits() {
|
||||
|
||||
@@ -71,7 +71,7 @@ pub async fn timeout_at<F: Future>(deadline: Instant, f: F) -> Result<F::Output,
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "_rt-async-std"))]
|
||||
missing_rt((duration, f))
|
||||
missing_rt((deadline, f))
|
||||
}
|
||||
|
||||
pub async fn sleep(duration: Duration) {
|
||||
|
||||
Reference in New Issue
Block a user