Skip to content

Commit 39f00fa

Browse files
committed
fix: compilation error, warnings
1 parent e33d23e commit 39f00fa

File tree

6 files changed

+15
-30
lines changed

6 files changed

+15
-30
lines changed

sqlx-core/src/error.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,13 @@ pub trait DatabaseError: 'static + Send + Sync + StdError {
263263
/// For example, the Postgres driver overrides this to return `true` for the following error codes:
264264
///
265265
/// * `53300 too_many_connections`: returned when the maximum connections are exceeded
266-
/// on the server. Assumed to be the result of a temporary overcommit
267-
/// (e.g. an extra application replica being spun up to replace one that is going down).
266+
/// on the server. Assumed to be the result of a temporary overcommit
267+
/// (e.g. an extra application replica being spun up to replace one that is going down).
268268
/// * This error being consistently logged or returned is a likely indicator of a misconfiguration;
269269
/// the sum of [`PoolOptions::max_connections`] for all replicas should not exceed
270270
/// the maximum connections allowed by the server.
271271
/// * `57P03 cannot_connect_now`: returned when the database server is still starting up
272-
/// and the tcop component is not ready to accept connections yet.
272+
/// and the tcop component is not ready to accept connections yet.
273273
fn is_retryable_connect_error(&self) -> bool {
274274
false
275275
}

sqlx-core/src/pool/connect.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
use crate::connection::{ConnectOptions, Connection};
22
use crate::database::Database;
3-
use crate::pool::connection::{Floating, Live};
3+
use crate::pool::connection::Floating;
44
use crate::pool::inner::PoolInner;
55
use crate::pool::PoolConnection;
66
use crate::rt::JoinHandle;
77
use crate::Error;
88
use ease_off::EaseOff;
9-
use event_listener::{Event, EventListener};
9+
use event_listener::Event;
1010
use std::fmt::{Display, Formatter};
1111
use std::future::Future;
12-
use std::pin::Pin;
1312
use std::ptr;
1413
use std::sync::atomic::{AtomicUsize, Ordering};
15-
use std::sync::{Arc, RwLock};
16-
use std::task::{Context, Poll};
17-
use std::time::{Duration, Instant};
18-
use tracing::Instrument;
14+
use std::sync::Arc;
15+
use std::time::Instant;
1916

2017
use std::io;
2118

@@ -74,7 +71,7 @@ use std::io;
7471
/// `set_connect_options` and `get_connect_options` were removed in 0.9.0 because they complicated
7572
/// the pool internals. They can be reimplemented by capturing a mutex, or similar, in the callback.
7673
///
77-
/// This example uses Postgres and [`tokio::sync::Mutex`] but may be adapted to any driver
74+
/// This example uses Postgres and [`tokio::sync::RwLock`] but may be adapted to any driver
7875
/// or `async-std`, respectively.
7976
///
8077
/// ```rust,no_run
@@ -197,11 +194,11 @@ pub trait PoolConnector<DB: Database>: Send + Sync + 'static {
197194
///
198195
/// * [`io::ErrorKind::ConnectionRefused`]
199196
/// * Database errors for which
200-
/// [`is_retryable_connect_error`][crate::error::DatabaseError::is_retryable_connect_error]
201-
/// returns `true`.
197+
/// [`is_retryable_connect_error`][crate::error::DatabaseError::is_retryable_connect_error]
198+
/// returns `true`.
202199
/// * [`Error::PoolConnector`] with `retryable: true`.
203-
/// This error kind is not returned internally and is designed to allow this method to return
204-
/// arbitrary error types not otherwise supported.
200+
/// This error kind is not returned internally and is designed to allow this method to return
201+
/// arbitrary error types not otherwise supported.
205202
///
206203
/// Manual implementations of this method may also use the signature:
207204
/// ```rust,ignore
@@ -363,7 +360,7 @@ impl ConnectionCounter {
363360
// Check that `self` can increase size first before we check the parent.
364361
let acquired = self.acquire_permit_self(pool).await;
365362

366-
if let Some(parent) = &pool.options.parent_pool {
363+
if let Some(parent) = pool.parent() {
367364
let (_, permit) = parent.0.counter.acquire_permit_self(&parent.0).await;
368365

369366
// consume the parent permit

sqlx-core/src/pool/connection.rs

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ use std::ops::{Deref, DerefMut};
33
use std::sync::Arc;
44
use std::time::{Duration, Instant};
55

6-
use crate::sync::AsyncSemaphoreReleaser;
7-
86
use crate::connection::Connection;
97
use crate::database::Database;
108
use crate::error::Error;

sqlx-core/src/pool/inner.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<DB: Database> PoolInner<DB> {
9090
}
9191
}
9292

93-
fn parent(&self) -> Option<&Pool<DB>> {
93+
pub(super) fn parent(&self) -> Option<&Pool<DB>> {
9494
self.options.parent_pool.as_ref()
9595
}
9696

sqlx-core/src/pool/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ use std::future::Future;
5959
use std::pin::Pin;
6060
use std::sync::Arc;
6161
use std::task::{Context, Poll};
62-
use std::time::{Duration, Instant};
6362

6463
use event_listener::EventListener;
6564
use futures_core::FusedFuture;
@@ -592,15 +591,6 @@ impl FusedFuture for CloseEvent {
592591
}
593592
}
594593

595-
/// get the time between the deadline and now and use that as our timeout
596-
///
597-
/// returns `Error::PoolTimedOut` if the deadline is in the past
598-
fn deadline_as_timeout(deadline: Instant) -> Result<Duration, Error> {
599-
deadline
600-
.checked_duration_since(Instant::now())
601-
.ok_or(Error::PoolTimedOut)
602-
}
603-
604594
#[test]
605595
#[allow(dead_code)]
606596
fn assert_pool_traits() {

sqlx-core/src/rt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub async fn timeout_at<F: Future>(deadline: Instant, f: F) -> Result<F::Output,
6262
}
6363

6464
#[cfg(not(feature = "_rt-async-std"))]
65-
missing_rt((duration, f))
65+
missing_rt((deadline, f))
6666
}
6767

6868
pub async fn sleep(duration: Duration) {

0 commit comments

Comments
 (0)