⬆️ deps: upgrade everything to Tokio 1.2.0

And pretend I didn't completely goober the Docker build somehow
main
_ 2021-03-06 21:15:41 +00:00
parent e0f5b229a1
commit a980d151fc
30 changed files with 392 additions and 465 deletions

575
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -23,16 +23,16 @@ exclude = [
[dependencies]
anyhow = "1.0.34"
anyhow = "1.0.38"
blake3 = "0.3.7"
tokio = { version = "0.2.22", features = ["full"] }
tracing-subscriber = "0.2.15"
reqwest = { version = "0.11.1", features = ["stream"] }
tokio = { version = "1.2.0", features = ["full"] }
tracing-subscriber = "0.2.16"
tracing = "0.1.25"
debug_proxy = { path = "crates/debug_proxy" }
ptth_relay = { path = "crates/ptth_relay" }
ptth_server = { path = "crates/ptth_server" }
reqwest = { version = "0.10.8", features = ["stream"] }
tracing = "0.1.21"
[dev-dependencies]

View File

@ -27,9 +27,6 @@ COPY ./Cargo.toml ./
COPY ./crates/always_equal/Cargo.toml ./crates/always_equal/
COPY ./crates/ptth_core/Cargo.toml ./crates/ptth_core/
COPY ./crates/ptth_relay/Cargo.toml ./crates/ptth_relay/
# COPY ./crates/ptth_server/Cargo.toml ./crates/ptth_server/
# COPY ./crates/ptth_file_server_bin/Cargo.toml ./crates/ptth_file_server_bin/
# COPY ./tools/ptth_tail/Cargo.toml ./tools/ptth_tail/
# this build step will cache your dependencies
RUN cargo build --release -p ptth_relay

View File

@ -9,10 +9,12 @@ license = "AGPL-3.0"
[dependencies]
anyhow = "1.0.34"
futures-util = "0.3.8"
http = "0.2.1"
hyper = "0.13.8"
reqwest = { version = "0.10.8", features = ["stream"] }
tokio = { version = "0.2.22", features = ["full"] }
hyper = { version = "0.14.4", features = ["server", "stream"] }
reqwest = "0.11.1"
tokio = "1.2.0"
tokio-stream = "0.1.3"
tracing = "0.1.21"
tracing-subscriber = "0.2.15"
ulid = "0.4.1"

View File

@ -3,6 +3,7 @@ use std::{
sync::Arc,
};
use futures_util::StreamExt;
use hyper::{
Body,
Request,
@ -16,12 +17,12 @@ use hyper::{
use reqwest::Client;
use tokio::{
spawn,
stream::StreamExt,
sync::{
mpsc,
oneshot,
},
};
use tokio_stream::wrappers::ReceiverStream;
use ulid::Ulid;
struct State {
@ -51,7 +52,7 @@ async fn handle_all (req: Request <Body>, state: Arc <State>)
upstream_req = upstream_req.header (k, v);
}
let (mut tx, rx) = mpsc::channel (1);
let (tx, rx) = mpsc::channel (1);
spawn ({
let req_id = req_id.clone ();
async move {
@ -78,7 +79,7 @@ async fn handle_all (req: Request <Body>, state: Arc <State>)
}
});
let upstream_resp = upstream_req.body (reqwest::Body::wrap_stream (rx)).send ().await?;
let upstream_resp = upstream_req.body (reqwest::Body::wrap_stream (ReceiverStream::new (rx))).send ().await?;
let mut resp = Response::builder ()
.status (upstream_resp.status ());
@ -87,7 +88,7 @@ async fn handle_all (req: Request <Body>, state: Arc <State>)
resp = resp.header (k, v);
}
let (mut tx, rx) = mpsc::channel (1);
let (tx, rx) = mpsc::channel (1);
spawn (async move {
let mut body = upstream_resp.bytes_stream ();
let mut bytes_transferred = 0;
@ -112,7 +113,7 @@ async fn handle_all (req: Request <Body>, state: Arc <State>)
Ok::<_, anyhow::Error> (())
});
Ok (resp.body (Body::wrap_stream (rx))?)
Ok (resp.body (Body::wrap_stream (ReceiverStream::new (rx)))?)
}
pub async fn run_proxy (

View File

@ -11,11 +11,11 @@ repository = "https://github.com/ReactorScram/ptth"
[dependencies]
ctrlc = { version = "3.1.7", features = [ "termination" ] }
ctrlc = { version = "3.1.8", features = [ "termination" ] }
futures = "0.3.7"
hyper = "0.13.8"
serde = {version = "1.0.117", features = ["derive"]}
thiserror = "1.0.22"
tokio = { version = "0.2.22", features = ["full"] }
tracing = "0.1.21"
tracing-futures = "0.2.4"
hyper = "0.14.4"
serde = {version = "1.0.124", features = ["derive"]}
thiserror = "1.0.24"
tokio = { version = "1.2.0", features = ["full"] }
tracing = "0.1.25"
tracing-futures = "0.2.5"

View File

@ -9,7 +9,7 @@ use std::{
use futures::prelude::*;
use tokio::{
sync::oneshot,
time::delay_for,
time::sleep,
};
use crate::prelude::*;
@ -82,7 +82,7 @@ impl ForcedShutdown {
self.tx.send (()).expect ("Error forwarding graceful shutdown signal");
let timeout = 5;
debug! ("Starting graceful shutdown. Forcing shutdown in {} seconds", timeout);
delay_for (Duration::from_secs (timeout)).await;
sleep (Duration::from_secs (timeout)).await;
error! ("Forcing shutdown");
};

View File

@ -175,7 +175,7 @@ impl Response {
self.content_length = b.len ().try_into ().ok ();
self.header ("content-length".to_string (), b.len ().to_string ().into_bytes ());
let (mut tx, rx) = tokio::sync::mpsc::channel (1);
let (tx, rx) = tokio::sync::mpsc::channel (1);
tokio::spawn (async move {
tx.send (Ok (b)).await.ok ();
});

View File

@ -8,16 +8,17 @@ license = "AGPL-3.0"
[dependencies]
anyhow = "1.0.34"
arc-swap = "1.1.0"
handlebars = "3.5.1"
anyhow = "1.0.38"
arc-swap = "1.2.0"
handlebars = "3.5.3"
http = "0.2.1"
hyper = "0.13.8"
serde = {version = "1.0.117", features = ["derive"]}
structopt = "0.3.20"
tokio = { version = "0.2.22", features = ["full"] }
tracing = "0.1.21"
tracing-subscriber = "0.2.15"
hyper = "0.14.4"
serde = {version = "1.0.124", features = ["derive"]}
structopt = "0.3.21"
tokio = { version = "1.2.0", features = [] }
tokio-stream = "0.1.3"
tracing = "0.1.25"
tracing-subscriber = "0.2.16"
uom = "0.30.0"
ptth_core = { path = "../ptth_core" }

View File

@ -19,6 +19,7 @@ use hyper::{
StatusCode,
};
use serde::Deserialize;
use tokio_stream::wrappers::ReceiverStream;
use tracing::debug;
use ptth_core::{
@ -70,7 +71,9 @@ async fn handle_all (req: Request <Body>, state: Arc <State>)
resp = resp.header (HeaderName::from_str (&k)?, v);
}
let body = ptth_resp.body.map_or_else (Body::empty, Body::wrap_stream);
let body = ptth_resp.body.map_or_else (Body::empty, |body| {
Body::wrap_stream (ReceiverStream::new (body))
});
Ok (resp.body (body)?)
}

View File

@ -7,17 +7,19 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.34"
base64 = "0.12.3"
anyhow = "1.0.38"
base64 = "0.13.0"
clap = "2.33.3"
futures = "0.3.7"
reqwest = { version = "0.10.8", features = ["stream"] }
rmp-serde = "0.14.4"
serde = {version = "1.0.117", features = ["derive"]}
serde_json = "1.0.60"
structopt = "0.3.20"
thiserror = "1.0.22"
tokio = { version = "0.2.22", features = ["full"] }
tracing = "0.1.21"
tracing-futures = "0.2.4"
tracing-subscriber = "0.2.15"
futures-util = "0.3.8"
reqwest = { version = "0.11.1", features = ["stream"] }
rmp-serde = "0.15.4"
serde = {version = "1.0.124", features = ["derive"]}
serde_json = "1.0.64"
structopt = "0.3.21"
thiserror = "1.0.24"
tokio = { version = "1.2.0", features = [] }
tokio-stream = "0.1.3"
tracing = "0.1.25"
tracing-futures = "0.2.5"
tracing-subscriber = "0.2.16"

View File

@ -1,4 +1,5 @@
use clap::{App, SubCommand};
use futures_util::StreamExt;
use reqwest::Client;
use tokio::{
io::{
@ -11,9 +12,9 @@ use tokio::{
tcp::OwnedReadHalf,
},
spawn,
stream::StreamExt,
sync::mpsc,
};
use tokio_stream::wrappers::ReceiverStream;
#[tokio::main]
async fn main () -> anyhow::Result <()> {
@ -37,7 +38,7 @@ async fn main () -> anyhow::Result <()> {
TcpStream::connect ("127.0.0.1:4010").await?
}
else if let Some (_matches) = matches.subcommand_matches ("client") {
let mut listener = TcpListener::bind ("127.0.0.1:4020").await?;
let listener = TcpListener::bind ("127.0.0.1:4020").await?;
let (stream, _addr) = listener.accept ().await?;
stream
}
@ -53,7 +54,7 @@ async fn main () -> anyhow::Result <()> {
handle_upstream (tcp_upstream, upstream_tx).await
});
let upstream = client.post ("http://127.0.0.1:4003/").body (reqwest::Body::wrap_stream (upstream_rx));
let upstream = client.post ("http://127.0.0.1:4003/").body (reqwest::Body::wrap_stream (ReceiverStream::new (upstream_rx)));
spawn (async move {
upstream.send ().await
@ -72,7 +73,7 @@ async fn main () -> anyhow::Result <()> {
async fn handle_upstream (
mut tcp_upstream: OwnedReadHalf,
mut upstream_tx: mpsc::Sender <Result <Vec <u8>, anyhow::Error>>
upstream_tx: mpsc::Sender <Result <Vec <u8>, anyhow::Error>>
) -> anyhow::Result <()> {
loop {
let mut buffer = vec! [0u8; 65_536];

View File

@ -7,12 +7,14 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0.34"
anyhow = "1.0.38"
futures = "0.3.7"
hyper = "0.13.8"
thiserror = "1.0.22"
tokio = { version = "0.2.22", features = ["full"] }
tracing = "0.1.21"
tracing-futures = "0.2.4"
tracing-subscriber = "0.2.15"
futures-util = "0.3.8"
hyper = "0.14.4"
thiserror = "1.0.24"
tokio = { version = "1.2.0", features = [] }
tokio-stream = "0.1.3"
tracing = "0.1.25"
tracing-futures = "0.2.5"
tracing-subscriber = "0.2.16"
ulid = "0.4.1"

View File

@ -4,6 +4,7 @@ use std::{
time::Duration,
};
use futures_util::StreamExt;
use hyper::{
Body,
Method,
@ -13,13 +14,13 @@ use hyper::{
};
use tokio::{
spawn,
stream::StreamExt,
sync::{
RwLock,
mpsc,
},
time::interval,
};
use tokio_stream::wrappers::ReceiverStream;
use tracing::{
info, trace,
};
@ -150,7 +151,7 @@ impl HttpService {
});
Ok::<_, anyhow::Error> (Response::builder ()
.body (Body::wrap_stream (rx))?)
.body (Body::wrap_stream (ReceiverStream::new (rx)))?)
}
async fn handle_posts (req: Request <Body>, state: &RelayState)
@ -168,7 +169,7 @@ impl HttpService {
.body (Body::from ("hello\n"))?)
}
async fn handle_downstream (mut tx: mpsc::Sender <anyhow::Result <String>>) -> Result <(), anyhow::Error> {
async fn handle_downstream (tx: mpsc::Sender <anyhow::Result <String>>) -> Result <(), anyhow::Error> {
let mut int = interval (Duration::from_secs (1));
let mut counter = 0u64;
@ -178,8 +179,6 @@ impl HttpService {
tx.send (Ok::<_, anyhow::Error> (format! ("Counter: {}\n", counter))).await?;
counter += 1;
}
Ok (())
}
}

View File

@ -5,8 +5,8 @@ authors = ["Trish"]
edition = "2018"
[dependencies]
anyhow = "1.0.34"
anyhow = "1.0.38"
base64 = "0.13.0"
hyper = "0.13.8"
hyper = { version = "0.14.4", features = ["full"] }
thiserror = "1.0.22"
tokio = { version = "0.2.22", features = ["full"] }
tokio = { version = "1.2.0", features = ["full"] }

View File

@ -63,7 +63,7 @@ impl HttpService {
use std::net::SocketAddr;
use hyper::{
server::Server,
Server,
service::{
make_service_fn,
service_fn,

View File

@ -8,24 +8,26 @@ license = "AGPL-3.0"
[dependencies]
base64 = "0.12.3"
base64 = "0.13.0"
blake3 = "0.3.7"
chrono = {version = "0.4.19", features = ["serde"]}
chrono = { version = "0.4.19", features = ["serde"] }
clap = "2.33.3"
dashmap = "3.11.10"
futures = "0.3.7"
handlebars = "3.5.1"
http = "0.2.1"
hyper = "0.13.8"
futures-util = "0.3.8"
handlebars = "3.5.3"
http = "0.2.3"
hyper = { version = "0.14.4", features = ["server", "stream"] }
itertools = "0.9.0"
rand = "0.6.5"
rmp-serde = "0.14.4"
serde = {version = "1.0.117", features = ["derive"]}
serde = { version = "1.0.117", features = ["derive"] }
serde_json = "1.0.60"
thiserror = "1.0.22"
tokio = { version = "0.2.22", features = ["full"] }
tokio = { version = "1.2.0", features = [] }
tokio-stream = "0.1.3"
toml = "0.5.7"
tracing = "0.1.21"
tracing = "0.1.25"
tracing-futures = "0.2.4"
tracing-subscriber = "0.2.15"
ulid = "0.4.1"

View File

@ -96,15 +96,7 @@ impl TryFrom <file::Config> for Config {
impl Config {
pub async fn from_file (path: &Path) -> Result <Self, ConfigError> {
use tokio::prelude::*;
let mut f = tokio::fs::File::open (path).await?;
let mut buffer = vec! [0_u8; 4096];
let bytes_read = f.read (&mut buffer).await?;
buffer.truncate (bytes_read);
let config_s = String::from_utf8 (buffer)?;
let config_s = tokio::fs::read_to_string (path).await?;
let new_config: file::Config = toml::from_str (&config_s)?;
Self::try_from (new_config)

View File

@ -29,6 +29,7 @@ use chrono::{
Utc
};
use dashmap::DashMap;
use futures_util::StreamExt;
use handlebars::Handlebars;
use hyper::{
Body,
@ -47,6 +48,7 @@ use tokio::{
oneshot,
},
};
use tokio_stream::wrappers::ReceiverStream;
use ptth_core::{
http_serde,
@ -166,7 +168,7 @@ async fn handle_http_request (
request_rendezvous.insert (watcher_code, new_rendezvous);
}
let timeout = tokio::time::delay_for (std::time::Duration::from_secs (30));
let timeout = tokio::time::sleep (std::time::Duration::from_secs (30));
let received = tokio::select! {
val = rx => val,
@ -305,8 +307,6 @@ async fn handle_server_list (
async fn handle_endless_sink (req: Request <Body>) -> Result <Response <Body>, http::Error>
{
use tokio::stream::StreamExt;
let (_parts, mut body) = req.into_parts ();
let mut bytes_received = 0;
@ -339,8 +339,6 @@ async fn handle_endless_source (gib: usize, throttle: Option <usize>)
let (tx, rx) = mpsc::channel (1);
tokio::spawn (async move {
let mut tx = tx;
let random_block = {
use rand::RngCore;
@ -374,7 +372,7 @@ async fn handle_endless_source (gib: usize, throttle: Option <usize>)
Response::builder ()
.status (StatusCode::OK)
.header ("content-type", "application/octet-stream")
.body (Body::wrap_stream (rx))
.body (Body::wrap_stream (ReceiverStream::new (rx)))
}
#[instrument (level = "trace", skip (req, state, handlebars))]
@ -564,7 +562,7 @@ pub async fn run_relay (
shutdown_oneshot.await.ok ();
state.shutdown_watch_tx.broadcast (true).expect ("Can't broadcast graceful shutdown");
state.shutdown_watch_tx.send (true).expect ("Can't broadcast graceful shutdown");
let mut response_rendezvous = state.response_rendezvous.write ().await;
let mut swapped = DashMap::default ();

View File

@ -20,8 +20,8 @@ use tokio::{
mpsc,
oneshot,
},
time::delay_for,
};
use tokio_stream::wrappers::ReceiverStream;
use ptth_core::{
http_serde,
@ -115,7 +115,7 @@ pub async fn handle_listen (
Ok (Err (ShuttingDownError::ShuttingDown)) => Ok (error_reply (StatusCode::SERVICE_UNAVAILABLE, "Server is shutting down, try again soon")?),
Err (_) => Ok (error_reply (StatusCode::INTERNAL_SERVER_ERROR, "Server error")?),
},
_ = delay_for (Duration::from_secs (30)).fuse () => {
_ = tokio::time::sleep (Duration::from_secs (30)).fuse () => {
trace! ("Timed out http_listen for server {}", watcher_code);
return Ok (error_reply (StatusCode::NO_CONTENT, "No requests now, long-poll again")?)
}
@ -151,12 +151,12 @@ pub async fn handle_response (
// Intercept the body packets here so we can check when the stream
// ends or errors out
let (mut body_tx, body_rx) = mpsc::channel (2);
let (body_tx, body_rx) = mpsc::channel (2);
let (body_finished_tx, body_finished_rx) = oneshot::channel ();
let mut shutdown_watch_rx = state.shutdown_watch_rx.clone ();
let relay_task = spawn (async move {
if shutdown_watch_rx.recv ().await == Some (false) {
if *shutdown_watch_rx.borrow () == false {
loop {
let item = body.next ().await;
@ -171,7 +171,7 @@ pub async fn handle_response (
body_finished_tx.send (ClientDisconnected).map_err (|_| LostServer)?;
break;
},
_ = shutdown_watch_rx.recv ().fuse () => {
_ = shutdown_watch_rx.changed ().fuse () => {
debug! ("Closing stream: relay is shutting down");
break;
},
@ -191,7 +191,7 @@ pub async fn handle_response (
Ok::<(), HandleHttpResponseError> (())
});
let body = Body::wrap_stream (body_rx);
let body = Body::wrap_stream (ReceiverStream::new (body_rx));
let tx = {
let response_rendezvous = state.response_rendezvous.read ().await;

View File

@ -8,10 +8,10 @@ license = "AGPL-3.0"
[dependencies]
aho-corasick = "0.7.14"
anyhow = "1.0.34"
arc-swap = "1.1.0"
base64 = "0.12.3"
aho-corasick = "0.7.15"
anyhow = "1.0.38"
arc-swap = "1.2.0"
base64 = "0.13.0"
blake3 = "0.3.7"
chrono = {version = "0.4.19", features = ["serde"]}
futures = "0.3.7"
@ -22,16 +22,17 @@ lazy_static = "1.4.0"
percent-encoding = "2.1.0"
pulldown-cmark = "0.8.0"
regex = "1.4.1"
reqwest = { version = "0.10.8", features = ["stream"] }
reqwest = { version = "0.11.1", features = [] }
rmp-serde = "0.14.4"
serde = {version = "1.0.117", features = ["derive"]}
serde_json = "1.0.60"
structopt = "0.3.20"
thiserror = "1.0.22"
tokio = { version = "0.2.22", features = ["full"] }
tracing = "0.1.21"
tracing-futures = "0.2.4"
tracing-subscriber = "0.2.15"
thiserror = "1.0.24"
tokio = { version = "1.2.0", features = [] }
tokio-stream = "0.1.3"
tracing = "0.1.25"
tracing-futures = "0.2.5"
tracing-subscriber = "0.2.16"
toml = "0.5.7"
ulid = "0.4.1"
uom = "0.30.0"
@ -42,4 +43,4 @@ ptth_core = { path = "../ptth_core" }
[dev-dependencies]
maplit = "1.0.2"
rand = "0.6.5"
rand = "0.8.3"

View File

@ -41,7 +41,7 @@ fn main () -> Result <(), anyhow::Error> {
return Ok (());
}
let mut rt = runtime::Runtime::new ()?;
let rt = runtime::Runtime::new ()?;
rt.block_on (async move {
run_server (

View File

@ -82,8 +82,6 @@ impl Interval {
use heim::process;
use uom::si::{
information::mebibyte,
ratio,
time::second,
};
let our_process = process::current ().await?;

View File

@ -24,7 +24,10 @@ use tokio::{
File,
ReadDir,
},
io::AsyncReadExt,
io::{
AsyncReadExt,
AsyncSeekExt,
},
sync::mpsc::{
channel,
},
@ -141,7 +144,6 @@ async fn serve_file (
if should_send_body {
tokio::spawn (async move {
let mut tx = tx;
let mut bytes_sent = 0;
let mut bytes_left = content_length;

View File

@ -64,7 +64,7 @@ fn file_server () {
use super::*;
tracing_subscriber::fmt ().try_init ().ok ();
let mut rt = Runtime::new ().expect ("Can't create runtime");
let rt = Runtime::new ().expect ("Can't create runtime");
rt.block_on (async {
let file_server_root = PathBuf::from ("./");

View File

@ -20,8 +20,8 @@ use tokio::{
sync::{
oneshot,
},
time::delay_for,
};
use tokio_stream::wrappers::ReceiverStream;
use ptth_core::{
http_serde,
@ -88,7 +88,7 @@ async fn handle_one_req (
resp_req = resp_req.header ("Content-Length", length.to_string ());
}
if let Some (body) = response.body {
resp_req = resp_req.body (reqwest::Body::wrap_stream (body));
resp_req = resp_req.body (reqwest::Body::wrap_stream (ReceiverStream::new (body)));
}
let req = resp_req.build ().map_err (ServerError::Step5Responding)?;
@ -231,14 +231,15 @@ pub async fn run_server (
// TODO: Extract loop body to function?
if backoff_delay > 0 {
let mut delay = delay_for (Duration::from_millis (backoff_delay)).fuse ();
let sleep = tokio::time::sleep (Duration::from_millis (backoff_delay));
tokio::pin! (sleep);
if futures::select! (
_ = delay => false,
_ = shutdown_oneshot => true,
) {
tokio::select! {
_ = &mut sleep => {},
_ = &mut shutdown_oneshot => {
info! ("Received graceful shutdown");
break;
},
}
}

View File

@ -10,7 +10,6 @@ use reqwest::Client;
use tokio::{
spawn,
sync::oneshot,
time::delay_for,
};
use tracing::{
debug,
@ -89,7 +88,7 @@ async fn main () -> anyhow::Result <()> {
})
};
delay_for (Duration::from_millis (1000)).await;
tokio::time::sleep (Duration::from_millis (1000)).await;
assert_eq! (relay_state.list_servers ().await, vec! [
server_name.to_string (),
@ -129,7 +128,7 @@ async fn main () -> anyhow::Result <()> {
assert_eq! (resp.status (), reqwest::StatusCode::NOT_FOUND);
delay_for (Duration::from_secs (60)).await;
tokio::time::sleep (Duration::from_secs (60)).await;
info! ("Shutting down end-to-end test");

View File

@ -12,7 +12,6 @@ use tokio::{
runtime::Runtime,
spawn,
sync::oneshot,
time::delay_for,
};
use reqwest::Client;
@ -24,7 +23,7 @@ use tracing::{debug, info};
async fn wait_for_any_server (relay_state: &ptth_relay::RelayState) {
for _ in 0..50 {
delay_for (Duration::from_millis (100)).await;
tokio::time::sleep (Duration::from_millis (100)).await;
if ! relay_state.list_servers ().await.is_empty () {
break;
}
@ -181,7 +180,7 @@ fn end_to_end () {
// and we don't care if another test already installed a subscriber.
//tracing_subscriber::fmt ().try_init ().ok ();
let mut rt = Runtime::new ().expect ("Can't create runtime for testing");
let rt = Runtime::new ().expect ("Can't create runtime for testing");
// Spawn the root task
rt.block_on (async {
@ -197,7 +196,6 @@ fn end_to_end () {
proxy_port,
relay_port,
};
let relay_url = testing_config.relay_url ();
let testing_relay = TestingRelay::new (&testing_config).await;
let testing_server = TestingServer::new (&testing_config).await;
@ -222,7 +220,7 @@ fn end_to_end () {
#[test]
fn debug_proxy () {
tracing_subscriber::fmt ().try_init ().ok ();
let mut rt = Runtime::new ().expect ("Can't create runtime for testing");
let rt = Runtime::new ().expect ("Can't create runtime for testing");
rt.block_on (async {
let relay_port = 4002;
@ -278,7 +276,7 @@ fn debug_proxy () {
#[test]
fn scraper_endpoints () {
let mut rt = Runtime::new ().expect ("Can't create runtime for testing");
let rt = Runtime::new ().expect ("Can't create runtime for testing");
rt.block_on (async {
use ptth_relay::*;
@ -334,7 +332,7 @@ fn scraper_endpoints () {
},
};
delay_for (Duration::from_millis (200)).await;
tokio::time::sleep (Duration::from_millis (200)).await;
}
let resp = resp.expect ("Reqwest repeatedly failed to connect to the relay");
let resp = resp.bytes ().await.expect ("Couldn't check if relay is up");

View File

@ -8,14 +8,15 @@ license = "AGPL-3.0"
[dependencies]
anyhow = "1.0.34"
tracing = "0.1.21"
tracing-subscriber = "0.2.15"
anyhow = "1.0.38"
futures-util = "0.3.8"
tracing = "0.1.25"
tracing-subscriber = "0.2.16"
[dependencies.reqwest]
version = "0.10.8"
version = "0.11.1"
features = ["stream"]
[dependencies.tokio]
version = "0.2.22"
version = "1.2.0"
features = ["full"]

View File

@ -7,12 +7,12 @@ use std::{
time::Duration,
};
use futures_util::StreamExt;
use reqwest::{
Client,
StatusCode,
};
use tokio::{
stream::StreamExt,
time::interval,
};
use tracing::{
@ -75,6 +75,4 @@ async fn main () -> Result <(), anyhow::Error> {
total_bytes_received += u64::try_from (chunk.len ())?;
}
}
Ok (())
}