Skip to content

Commit

Permalink
fix: compilation error, warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
abonander committed Nov 9, 2024
1 parent e33d23e commit 39f00fa
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 30 deletions.
6 changes: 3 additions & 3 deletions sqlx-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,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
}
Expand Down
23 changes: 10 additions & 13 deletions sqlx-core/src/pool/connect.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions sqlx-core/src/pool/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,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;
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/pool/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,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()
}

Expand Down
10 changes: 0 additions & 10 deletions sqlx-core/src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use std::task::{Context, Poll};
use std::time::{Duration, Instant};

use event_listener::EventListener;
use futures_core::FusedFuture;
Expand Down Expand Up @@ -592,15 +591,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() {
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/rt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,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) {
Expand Down

0 comments on commit 39f00fa

Please sign in to comment.