clean code
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::http::counter::{AtomicHttpCounter, HttpCounter};
|
||||
use crate::http::counter::AtomicHttpCounter;
|
||||
use crate::http::header_config::HeadersConfig;
|
||||
use crate::http::simple::HttpSwardArray;
|
||||
use crate::http::{RandomUrlGenerator, SimpleHttpRequest, SimpleHttpSward};
|
||||
@@ -166,7 +166,7 @@ impl IntegratedHttpSwardBuilder {
|
||||
// get the cookie
|
||||
let maybe_cookie = self
|
||||
.headers_config
|
||||
.get_cookie_jar(&url_example)
|
||||
.get_cookie_jar(url_example)
|
||||
.map(Arc::new);
|
||||
|
||||
// build the clients
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
pub mod counter;
|
||||
pub mod header_config;
|
||||
pub mod integrated;
|
||||
pub mod random;
|
||||
pub mod simple;
|
||||
pub mod integrated;
|
||||
pub mod header_config;
|
||||
pub mod counter;
|
||||
|
||||
pub use integrated::IntegratedHttpSward;
|
||||
pub use random::RandomUrlGenerator;
|
||||
pub use simple::{SimpleHttpRequest, SimpleHttpSward};
|
||||
pub use integrated::IntegratedHttpSward;
|
||||
@@ -3,6 +3,6 @@
|
||||
#![deny(clippy::expect_used)]
|
||||
|
||||
pub mod http;
|
||||
pub mod utils;
|
||||
pub mod tcp;
|
||||
pub mod udp;
|
||||
pub mod udp;
|
||||
pub mod utils;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
pub mod ack;
|
||||
pub mod syn;
|
||||
pub mod syn;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use rand::RngCore;
|
||||
use crate::udp::{BoxedUdpRequest, SizedUdpRequest};
|
||||
use rand::RngCore;
|
||||
|
||||
pub struct RandomUdpWorkloadGenerator<Rng: RngCore> {
|
||||
rng: Rng,
|
||||
@@ -12,13 +12,11 @@ impl<Rng: RngCore> RandomUdpWorkloadGenerator<Rng> {
|
||||
pub fn generate_sized<const SIZE: usize>(&mut self) -> SizedUdpRequest<SIZE> {
|
||||
let mut buf = [0u8; SIZE];
|
||||
self.rng.fill_bytes(&mut buf);
|
||||
SizedUdpRequest {
|
||||
bytes: buf
|
||||
}
|
||||
SizedUdpRequest { bytes: buf }
|
||||
}
|
||||
pub fn generate_boxed(&mut self, size: usize) -> BoxedUdpRequest {
|
||||
let mut buf = vec![0u8; size].into_boxed_slice();
|
||||
self.rng.fill_bytes(&mut buf);
|
||||
BoxedUdpRequest(buf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
mod counter;
|
||||
pub mod generator;
|
||||
pub mod integrated;
|
||||
pub mod random_flood;
|
||||
mod counter;
|
||||
|
||||
pub use generator::RandomUdpWorkloadGenerator;
|
||||
pub use integrated::IntegratedUdpSward;
|
||||
|
||||
@@ -36,9 +36,7 @@ impl<const N: usize> Service<SizedUdpRequest<N>> for UdpSward {
|
||||
fn call(&mut self, req: SizedUdpRequest<N>) -> Self::Future {
|
||||
self.sent_count += 1;
|
||||
let socket = self.socket.clone();
|
||||
Box::pin(async move {
|
||||
socket.send(&req.bytes).await
|
||||
})
|
||||
Box::pin(async move { socket.send(&req.bytes).await })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,9 +53,7 @@ impl Service<BoxedUdpRequest> for UdpSward {
|
||||
fn call(&mut self, req: BoxedUdpRequest) -> Self::Future {
|
||||
self.sent_count += 1;
|
||||
let socket = self.socket.clone();
|
||||
Box::pin(async move {
|
||||
socket.send(&req.0).await
|
||||
})
|
||||
Box::pin(async move { socket.send(&req.0).await })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,4 +62,4 @@ impl tower::load::Load for UdpSward {
|
||||
fn load(&self) -> Self::Metric {
|
||||
self.sent_count
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user