Skip to content

Commit b6d4757

Browse files
committed
WIP feat: integrate sharding into pool (6)
1 parent c3a336e commit b6d4757

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

sqlx-core/src/pool/inner.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ impl<DB: Database> PoolInner<DB> {
176176
.fuse();
177177
}
178178

179+
// Try to acquire another connected connection.
179180
acquire_connected.set(self.acquire_connected().fuse());
180181
continue;
181182
}

sqlx-core/src/pool/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ fn default_shards() -> NonZero<usize> {
632632
#[cfg(feature = "_rt-async-std")]
633633
if let Some(val) = std::env::var("ASYNC_STD_THREAD_COUNT")
634634
.ok()
635-
.and_then(|s| s.parse())
635+
.and_then(|s| s.parse().ok())
636636
{
637637
return val;
638638
}

sqlx-core/src/rt/rt_async_io/time.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
use std::{future::Future, pin::pin, time::Duration};
1+
use std::{
2+
future::Future,
3+
pin::pin,
4+
time::{Duration, Instant},
5+
};
26

37
use futures_util::future::{select, Either};
48

59
use crate::rt::TimeoutError;
610

7-
pub fn sleep(duration: Duration) {
11+
pub async fn sleep(duration: Duration) {
812
async_io::Timer::after(duration).await;
913
}
1014

@@ -13,7 +17,7 @@ pub async fn sleep_until(deadline: Instant) {
1317
}
1418

1519
pub async fn timeout<F: Future>(duration: Duration, future: F) -> Result<F::Output, TimeoutError> {
16-
match select(pin!(future), sleep(duration)).await {
20+
match select(pin!(future), pin!(sleep(duration))).await {
1721
Either::Left((result, _)) => Ok(result),
1822
Either::Right(_) => Err(TimeoutError),
1923
}

0 commit comments

Comments
 (0)