Detailed changes
@@ -307,17 +307,6 @@ dependencies = [
"syn",
]
-[[package]]
-name = "async-rustls"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c86f33abd5a4f3e2d6d9251a9e0c6a7e52eb1113caf893dae8429bf4a53f378"
-dependencies = [
- "futures-lite",
- "rustls",
- "webpki",
-]
-
[[package]]
name = "async-std"
version = "1.9.0"
@@ -328,7 +317,6 @@ dependencies = [
"async-global-executor",
"async-io",
"async-lock",
- "async-process",
"crossbeam-utils 0.8.2",
"futures-channel",
"futures-core",
@@ -4568,6 +4556,7 @@ dependencies = [
"stringprep",
"thiserror",
"time 0.2.27",
+ "tokio-stream",
"url",
"uuid",
"webpki",
@@ -4601,8 +4590,9 @@ version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8199b421ecf3493ee9ef3e7bc90c904844cfb2ea7ea2f57347a93f52bfd3e057"
dependencies = [
- "async-rustls",
- "async-std",
+ "once_cell",
+ "tokio",
+ "tokio-rustls",
]
[[package]]
@@ -5078,6 +5068,28 @@ dependencies = [
"syn",
]
+[[package]]
+name = "tokio-rustls"
+version = "0.22.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
+dependencies = [
+ "rustls",
+ "tokio",
+ "webpki",
+]
+
+[[package]]
+name = "tokio-stream"
+version = "0.1.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "50145484efff8818b5ccd256697f36863f587da82cf8b409c53adf1e840798e3"
+dependencies = [
+ "futures-core",
+ "pin-project-lite 0.2.8",
+ "tokio",
+]
+
[[package]]
name = "tokio-tungstenite"
version = "0.17.1"
@@ -5500,7 +5512,6 @@ dependencies = [
"log",
"rand 0.8.3",
"serde_json",
- "surf",
"tempdir",
]
@@ -43,7 +43,7 @@ toml = "0.5.8"
[dependencies.sqlx]
version = "0.5.2"
-features = ["runtime-async-std-rustls", "postgres", "time", "uuid"]
+features = ["runtime-tokio-rustls", "postgres", "time", "uuid"]
[dev-dependencies]
collections = { path = "../collections", features = ["test-support"] }
@@ -1,4 +1,4 @@
-use db::{Db, UserId};
+use db::{Db, PostgresDb, UserId};
use rand::prelude::*;
use time::{Duration, OffsetDateTime};
@@ -6,11 +6,11 @@ use time::{Duration, OffsetDateTime};
#[path = "../db.rs"]
mod db;
-#[async_std::main]
+#[tokio::main]
async fn main() {
let mut rng = StdRng::from_entropy();
let database_url = std::env::var("DATABASE_URL").expect("missing DATABASE_URL env var");
- let db = Db::new(&database_url, 5)
+ let db = PostgresDb::new(&database_url, 5)
.await
.expect("failed to connect to postgres database");
@@ -14,7 +14,6 @@ anyhow = "1.0.38"
futures = "0.3"
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
rand = { version = "0.8", optional = true }
-surf = "2.2"
tempdir = { version = "0.3.7", optional = true }
serde_json = { version = "1.0.64", features = [
"preserve_order",
@@ -153,33 +153,3 @@ mod tests {
assert_eq!(vec, &[1000, 101, 21, 19, 17, 13, 9, 8]);
}
}
-
-// Allow surf Results to accept context like other Results do when
-// using anyhow.
-pub trait SurfResultExt {
- fn context<C>(self, cx: C) -> Self
- where
- C: std::fmt::Display + Send + Sync + 'static;
-
- fn with_context<C, F>(self, f: F) -> Self
- where
- C: std::fmt::Display + Send + Sync + 'static,
- F: FnOnce() -> C;
-}
-
-impl<T> SurfResultExt for surf::Result<T> {
- fn context<C>(self, cx: C) -> Self
- where
- C: std::fmt::Display + Send + Sync + 'static,
- {
- self.map_err(|e| surf::Error::new(e.status(), e.into_inner().context(cx)))
- }
-
- fn with_context<C, F>(self, f: F) -> Self
- where
- C: std::fmt::Display + Send + Sync + 'static,
- F: FnOnce() -> C,
- {
- self.map_err(|e| surf::Error::new(e.status(), e.into_inner().context(f())))
- }
-}