Spaces:
Runtime error
Runtime error
neon_arch
commited on
Commit
•
3742893
1
Parent(s):
89ee79c
♻️ refactor: reimplement the random delay code without the rand crate (#380)
Browse files
src/results/aggregator.rs
CHANGED
@@ -8,8 +8,8 @@ use crate::models::{
|
|
8 |
engine_models::{EngineError, EngineHandler},
|
9 |
};
|
10 |
use error_stack::Report;
|
11 |
-
use rand::Rng;
|
12 |
use regex::Regex;
|
|
|
13 |
use std::{
|
14 |
collections::HashMap,
|
15 |
io::{BufReader, Read},
|
@@ -72,9 +72,9 @@ pub async fn aggregate(
|
|
72 |
|
73 |
// Add a random delay before making the request.
|
74 |
if random_delay || !debug {
|
75 |
-
let
|
76 |
-
let
|
77 |
-
tokio::time::sleep(Duration::from_secs(
|
78 |
}
|
79 |
|
80 |
let mut names: Vec<&str> = Vec::with_capacity(0);
|
|
|
8 |
engine_models::{EngineError, EngineHandler},
|
9 |
};
|
10 |
use error_stack::Report;
|
|
|
11 |
use regex::Regex;
|
12 |
+
use std::time::{SystemTime, UNIX_EPOCH};
|
13 |
use std::{
|
14 |
collections::HashMap,
|
15 |
io::{BufReader, Read},
|
|
|
72 |
|
73 |
// Add a random delay before making the request.
|
74 |
if random_delay || !debug {
|
75 |
+
let nanos = SystemTime::now().duration_since(UNIX_EPOCH)?.subsec_nanos() as f32;
|
76 |
+
let delay = ((nanos / 1_0000_0000 as f32).floor() as u64) + 1;
|
77 |
+
tokio::time::sleep(Duration::from_secs(delay)).await;
|
78 |
}
|
79 |
|
80 |
let mut names: Vec<&str> = Vec::with_capacity(0);
|