Skip to content

Commit

Permalink
fix compile-time errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyandrews committed Nov 1, 2020
1 parent 4e7439e commit 04e0b72
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -28,7 +28,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_cbor = "0.11"
serde_json = "1.0"
simplelog = "0.8"
tokio = { version = "0.3", features = ["fs", "io-util", "macros", "rt", "sync", "time"] }
tokio = { version = "0.3", features = ["fs", "io-util", "macros", "rt-multi-thread", "sync", "time"] }
url = "2.1"

# optional dependencies
Expand Down
13 changes: 7 additions & 6 deletions src/lib.rs
Expand Up @@ -433,6 +433,7 @@ use std::{f32, fmt, io, time};
use tokio::fs::File;
use tokio::io::BufWriter;
use tokio::prelude::*;
use tokio::runtime::Runtime;
use tokio::sync::mpsc;
use url::Url;

Expand Down Expand Up @@ -2019,7 +2020,7 @@ impl GooseAttack {
if self.attack_mode == GooseMode::Manager {
#[cfg(feature = "gaggle")]
{
let mut rt = tokio::runtime::Runtime::new().unwrap();
let rt = Runtime::new().unwrap();
self = rt.block_on(manager::manager_main(self));
}

Expand All @@ -2034,7 +2035,7 @@ impl GooseAttack {
else if self.attack_mode == GooseMode::Worker {
#[cfg(feature = "gaggle")]
{
let mut rt = tokio::runtime::Runtime::new().unwrap();
let rt = Runtime::new().unwrap();
self = rt.block_on(worker::worker_main(&self));
}

Expand All @@ -2048,7 +2049,7 @@ impl GooseAttack {
}
// Start goose in single-process mode.
else {
let mut rt = tokio::runtime::Runtime::new().unwrap();
let rt = Runtime::new().unwrap();
self = rt.block_on(self.launch_users(sleep_duration, None))?;
}

Expand Down Expand Up @@ -2164,7 +2165,7 @@ impl GooseAttack {
throttle_rx,
)));

let mut sender = all_threads_throttle.clone();
let sender = all_threads_throttle.clone();
// We start from 1 instead of 0 to intentionally fill all but one slot in the
// channel to avoid a burst of traffic during startup. The channel then provides
// an implementation of the leaky bucket algorithm as a queue. Requests have to
Expand Down Expand Up @@ -2501,7 +2502,7 @@ impl GooseAttack {
}

// If throttle is enabled, tell throttle thread the load test is over.
if let Some(mut tx) = parent_to_throttle_tx {
if let Some(tx) = parent_to_throttle_tx {
let _ = tx.send(false).await;
}

Expand Down Expand Up @@ -2552,7 +2553,7 @@ impl GooseAttack {
}

let one_second = time::Duration::from_secs(1);
tokio::time::delay_for(one_second).await;
tokio::time::sleep(one_second).await;
}
self.metrics.duration = self.started.unwrap().elapsed().as_secs() as usize;

Expand Down
2 changes: 1 addition & 1 deletion src/user.rs
Expand Up @@ -132,7 +132,7 @@ pub async fn user_main(
"user {} from {} sleeping {:?} second...",
thread_number, thread_task_set.name, sleep_duration
);
tokio::time::delay_for(sleep_duration).await;
tokio::time::sleep(sleep_duration).await;
slept += 1;
if slept > wait_time {
in_sleep_loop = false;
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Expand Up @@ -52,7 +52,7 @@ pub async fn sleep_minus_drift(
drift: tokio::time::Instant,
) -> tokio::time::Instant {
match duration.checked_sub(drift.elapsed()) {
Some(delay) if delay.as_nanos() > 0 => tokio::time::delay_for(delay).await,
Some(delay) if delay.as_nanos() > 0 => tokio::time::sleep(delay).await,
_ => warn!("sleep_minus_drift: drift was greater than or equal to duration, not sleeping"),
};
tokio::time::Instant::now()
Expand Down
4 changes: 2 additions & 2 deletions tests/sequence.rs
@@ -1,7 +1,7 @@
use httpmock::Method::GET;
use httpmock::{Mock, MockRef, MockServer};
use serial_test::serial;
use tokio::time::{delay_for, Duration};
use tokio::time::{sleep, Duration};

mod common;

Expand Down Expand Up @@ -50,7 +50,7 @@ pub async fn two_with_delay(user: &GooseUser) -> GooseTaskResult {
// "Run out the clock" on the load test when this function runs. Sleep for
// the total duration the test is to run plus 1 second to be sure no
// additional tasks will run after this one.
delay_for(Duration::from_secs(RUN_TIME as u64 + 1)).await;
sleep(Duration::from_secs(RUN_TIME as u64 + 1)).await;

Ok(())
}
Expand Down

0 comments on commit 04e0b72

Please sign in to comment.