Skip to content

Commit ddcf4ed

Browse files
Smol executor isolated
1 parent 8cc0f5c commit ddcf4ed

File tree

15 files changed

+20
-223
lines changed

15 files changed

+20
-223
lines changed

Cargo.lock

Lines changed: 1 addition & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ authors = [
3535
"Chloe Ross <orangesnowfox@gmail.com>",
3636
"Daniel Akhterov <akhterovd@gmail.com>",
3737
]
38-
rust-version = "1.80.0"
38+
# TODO: enable this for 0.9.0
39+
# rust-version = "1.80.0"
3940

4041
[package]
4142
name = "sqlx"
@@ -75,7 +76,6 @@ _unstable-all-types = [
7576
]
7677

7778
# Base runtime features without TLS
78-
runtime-async-global-executor = ["_rt-async-global-executor", "sqlx-core/_rt-async-global-executor", "sqlx-macros?/_rt-async-global-executor"]
7979
runtime-async-std = ["_rt-async-std", "sqlx-core/_rt-async-std", "sqlx-macros?/_rt-async-std"]
8080
runtime-smol = ["_rt-smol", "sqlx-core/_rt-smol", "sqlx-macros?/_rt-smol"]
8181
runtime-tokio = ["_rt-tokio", "sqlx-core/_rt-tokio", "sqlx-macros?/_rt-tokio"]
@@ -93,9 +93,6 @@ tls-none = []
9393

9494
# Legacy Runtime + TLS features
9595

96-
runtime-async-global-executor-native-tls = ["runtime-async-global-executor", "tls-native-tls"]
97-
runtime-async-global-executor-rustls = ["runtime-async-global-executor", "tls-rustls-ring"]
98-
9996
runtime-async-std-native-tls = ["runtime-async-std", "tls-native-tls"]
10097
runtime-async-std-rustls = ["runtime-async-std", "tls-rustls-ring"]
10198

@@ -106,7 +103,6 @@ runtime-tokio-native-tls = ["runtime-tokio", "tls-native-tls"]
106103
runtime-tokio-rustls = ["runtime-tokio", "tls-rustls-ring"]
107104

108105
# for conditional compilation
109-
_rt-async-global-executor = []
110106
_rt-async-std = []
111107
_rt-smol = []
112108
_rt-tokio = []
@@ -164,11 +160,6 @@ cfg-if = "1.0.0"
164160
dotenvy = { version = "0.15.0", default-features = false }
165161

166162
# Runtimes
167-
[workspace.dependencies.async-global-executor]
168-
version = "3.1"
169-
default-features = false
170-
features = ["async-io"]
171-
172163
[workspace.dependencies.async-std]
173164
version = "1.12"
174165

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Note: should NOT increase during a minor/patch release cycle
22
[toolchain]
3-
channel = "1.80"
3+
channel = "1.78"
44
profile = "minimal"

sqlx-core/Cargo.toml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,7 @@ any = []
1919
json = ["serde", "serde_json"]
2020

2121
# for conditional compilation
22-
_rt-async-global-executor = [
23-
"async-global-executor",
24-
"async-io-global-executor",
25-
"async-lock",
26-
"async-net",
27-
]
28-
_rt-async-std = ["async-std", "async-io-std"]
22+
_rt-async-std = ["async-std", "async-io"]
2923
_rt-smol = ["smol"]
3024
_rt-tokio = ["tokio", "tokio-stream"]
3125
_tls-native-tls = ["native-tls"]
@@ -40,7 +34,6 @@ offline = ["serde", "either/serde"]
4034

4135
[dependencies]
4236
# Runtimes
43-
async-global-executor = { workspace = true, optional = true }
4437
async-std = { workspace = true, optional = true }
4538
smol = { workspace = true, optional = true }
4639
tokio = { workspace = true, optional = true }
@@ -61,10 +54,7 @@ ipnetwork = { workspace = true, optional = true }
6154
mac_address = { workspace = true, optional = true }
6255
uuid = { workspace = true, optional = true }
6356

64-
async-io-global-executor = { package = "async-io", version = "2.2", optional = true }
65-
async-io-std = { package = "async-io", version = "1.9.0", optional = true }
66-
async-lock = { version = "3.4.0", optional = true }
67-
async-net = { package = "async-net", version = "2.0.0", optional = true }
57+
async-io = { package = "async-io", version = "1.9.0", optional = true }
6858
base64 = { version = "0.22.0", default-features = false, features = ["std"] }
6959
bytes = "1.1.0"
7060
cfg-if = { workspace = true }

sqlx-core/src/net/socket/mod.rs

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -204,39 +204,8 @@ pub async fn connect_tcp<Ws: WithSocket>(
204204
}
205205

206206
cfg_if! {
207-
if #[cfg(feature = "_rt-async-global-executor")] {
208-
use async_io_global_executor::Async;
209-
use async_net::resolve;
210-
use std::net::TcpStream;
211-
212-
let mut last_err = None;
213-
214-
// Loop through all the Socket Addresses that the hostname resolves to
215-
for socket_addr in resolve((host, port)).await? {
216-
let stream = Async::<TcpStream>::connect(socket_addr)
217-
.await
218-
.and_then(|s| {
219-
s.get_ref().set_nodelay(true)?;
220-
Ok(s)
221-
});
222-
match stream {
223-
Ok(stream) => return Ok(with_socket.with_socket(stream).await),
224-
Err(e) => last_err = Some(e),
225-
}
226-
}
227-
228-
// If we reach this point, it means we failed to connect to any of the addresses.
229-
// Return the last error we encountered, or a custom error if the hostname didn't resolve to any address.
230-
Err(match last_err {
231-
Some(err) => err,
232-
None => io::Error::new(
233-
io::ErrorKind::AddrNotAvailable,
234-
"Hostname did not resolve to any addresses",
235-
),
236-
}
237-
.into())
238-
} else if #[cfg(feature = "_rt-async-std")] {
239-
use async_io_std::Async;
207+
if #[cfg(feature = "_rt-async-std")] {
208+
use async_io::Async;
240209
use async_std::net::ToSocketAddrs;
241210
use std::net::TcpStream;
242211

@@ -322,15 +291,8 @@ pub async fn connect_uds<P: AsRef<Path>, Ws: WithSocket>(
322291
}
323292

324293
cfg_if! {
325-
if #[cfg(feature = "_rt-async-global-executor")] {
326-
use async_io_global_executor::Async;
327-
use std::os::unix::net::UnixStream;
328-
329-
let stream = Async::<UnixStream>::connect(path).await?;
330-
331-
Ok(with_socket.with_socket(stream).await)
332-
} else if #[cfg(feature = "_rt-async-std")] {
333-
use async_io_std::Async;
294+
if #[cfg(feature = "_rt-async-std")] {
295+
use async_io::Async;
334296
use std::os::unix::net::UnixStream;
335297

336298
let stream = Async::<UnixStream>::connect(path).await?;

sqlx-core/src/rt/mod.rs

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@ use std::time::Duration;
77
use cfg_if::cfg_if;
88

99
#[cfg(any(
10-
feature = "_rt-async-global-executor",
1110
feature = "_rt-async-std",
1211
feature = "_rt-smol"
1312
))]
1413
pub mod rt_async_io;
1514

16-
#[cfg(feature = "_rt-async-global-executor")]
17-
pub mod rt_async_global_executor;
18-
1915
#[cfg(feature = "_rt-smol")]
2016
pub mod rt_smol;
2117

@@ -27,8 +23,6 @@ pub mod rt_tokio;
2723
pub struct TimeoutError;
2824

2925
pub enum JoinHandle<T> {
30-
#[cfg(feature = "_rt-async-global-executor")]
31-
AsyncGlobalExecutor(rt_async_global_executor::JoinHandle<T>),
3226
#[cfg(feature = "_rt-async-std")]
3327
AsyncStd(async_std::task::JoinHandle<T>),
3428
#[cfg(feature = "_rt-smol")]
@@ -48,9 +42,7 @@ pub async fn timeout<F: Future>(duration: Duration, f: F) -> Result<F::Output, T
4842
}
4943

5044
cfg_if! {
51-
if #[cfg(feature = "_rt-async-global-executor")] {
52-
rt_async_global_executor::timeout(duration, f).await
53-
} else if #[cfg(feature = "_rt-async-std")] {
45+
if #[cfg(feature = "_rt-async-std")] {
5446
async_std::future::timeout(duration, f)
5547
.await
5648
.map_err(|_| TimeoutError)
@@ -69,9 +61,7 @@ pub async fn sleep(duration: Duration) {
6961
}
7062

7163
cfg_if! {
72-
if #[cfg(feature = "_rt-async-global-executor")] {
73-
rt_async_global_executor::sleep(duration).await
74-
} else if #[cfg(feature = "_rt-async-std")] {
64+
if #[cfg(feature = "_rt-async-std")] {
7565
async_std::task::sleep(duration).await
7666
} else if #[cfg(feature = "_rt-smol")] {
7767
rt_smol::sleep(duration).await
@@ -93,11 +83,7 @@ where
9383
}
9484

9585
cfg_if! {
96-
if #[cfg(feature = "_rt-async-global-executor")] {
97-
JoinHandle::AsyncGlobalExecutor(rt_async_global_executor::JoinHandle {
98-
task: Some(async_global_executor::spawn(fut)),
99-
})
100-
} else if #[cfg(feature = "_rt-async-std")] {
86+
if #[cfg(feature = "_rt-async-std")] {
10187
JoinHandle::AsyncStd(async_std::task::spawn(fut))
10288
} else if #[cfg(feature = "_rt-smol")] {
10389
JoinHandle::Smol(rt_smol::JoinHandle {
@@ -121,11 +107,7 @@ where
121107
}
122108

123109
cfg_if! {
124-
if #[cfg(feature = "_rt-async-global-executor")] {
125-
JoinHandle::AsyncGlobalExecutor(rt_async_global_executor::JoinHandle {
126-
task: Some(async_global_executor::spawn_blocking(f)),
127-
})
128-
} else if #[cfg(feature = "_rt-async-std")] {
110+
if #[cfg(feature = "_rt-async-std")] {
129111
JoinHandle::AsyncStd(async_std::task::spawn_blocking(f))
130112
} else if #[cfg(feature = "_rt-smol")] {
131113
JoinHandle::Smol(rt_smol::JoinHandle {
@@ -144,9 +126,7 @@ pub async fn yield_now() {
144126
}
145127

146128
cfg_if! {
147-
if #[cfg(feature = "_rt-async-global-executor")] {
148-
rt_async_global_executor::yield_now().await
149-
} else if #[cfg(feature = "_rt-async-std")] {
129+
if #[cfg(feature = "_rt-async-std")] {
150130
async_std::task::yield_now().await
151131
} else if #[cfg(feature = "_rt-smol")] {
152132
smol::future::yield_now().await
@@ -170,9 +150,7 @@ pub fn test_block_on<F: Future>(f: F) -> F::Output {
170150
}
171151

172152
cfg_if! {
173-
if #[cfg(feature = "_rt-async-global-executor")] {
174-
async_io_global_executor::block_on(f)
175-
} else if #[cfg(feature = "_rt-async-std")] {
153+
if #[cfg(feature = "_rt-async-std")] {
176154
async_std::task::block_on(f)
177155
} else if #[cfg(feature = "_rt-smol")] {
178156
smol::block_on(f)
@@ -188,7 +166,7 @@ pub fn missing_rt<T>(_unused: T) -> ! {
188166
panic!("this functionality requires a Tokio context")
189167
}
190168

191-
panic!("one of the `runtime-async-global-executor`, `runtime-async-std`, `runtime-smol`, or `runtime-tokio` feature must be enabled")
169+
panic!("one of the `runtime-async-std`, `runtime-smol`, or `runtime-tokio` feature must be enabled")
192170
}
193171

194172
impl<T: Send + 'static> Future for JoinHandle<T> {
@@ -197,8 +175,6 @@ impl<T: Send + 'static> Future for JoinHandle<T> {
197175
#[track_caller]
198176
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
199177
match &mut *self {
200-
#[cfg(feature = "_rt-async-global-executor")]
201-
Self::AsyncGlobalExecutor(handle) => Pin::new(handle).poll(cx),
202178
#[cfg(feature = "_rt-async-std")]
203179
Self::AsyncStd(handle) => Pin::new(handle).poll(cx),
204180
#[cfg(feature = "_rt-smol")]

sqlx-core/src/rt/rt_async_global_executor/join_handle.rs

Lines changed: 0 additions & 30 deletions
This file was deleted.

sqlx-core/src/rt/rt_async_global_executor/mod.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

sqlx-core/src/rt/rt_async_global_executor/timeout.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)