aquatic: Config: add fields for max handler request, channel timeout

This commit is contained in:
Joakim Frostegård 2020-04-12 13:26:44 +02:00
parent e61c961126
commit 5430e561f5
3 changed files with 24 additions and 5 deletions

View file

@ -9,6 +9,7 @@ pub struct Config {
pub socket_workers: usize,
pub response_workers: usize,
pub network: NetworkConfig,
pub handlers: HandlerConfig,
pub statistics: StatisticsConfig,
pub cleaning: CleaningConfig,
}
@ -30,6 +31,13 @@ pub struct NetworkConfig {
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct HandlerConfig {
pub max_requests_per_iter: usize,
pub channel_recv_timeout_ms: u64,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct StatisticsConfig {
/// Print statistics this often (seconds). Don't print when set to zero.
@ -54,6 +62,7 @@ impl Default for Config {
socket_workers: 1,
response_workers: 1,
network: NetworkConfig::default(),
handlers: HandlerConfig::default(),
statistics: StatisticsConfig::default(),
cleaning: CleaningConfig::default(),
}
@ -75,6 +84,16 @@ impl Default for NetworkConfig {
}
impl Default for HandlerConfig {
fn default() -> Self {
Self {
max_requests_per_iter: 2048,
channel_recv_timeout_ms: 1,
}
}
}
impl Default for StatisticsConfig {
fn default() -> Self {
Self {

View file

@ -26,10 +26,12 @@ pub fn handle(
let mut std_rng = StdRng::from_entropy();
let mut small_rng = SmallRng::from_rng(&mut std_rng).unwrap();
let timeout = Duration::from_millis(10);
let timeout = Duration::from_millis(
config.handlers.channel_recv_timeout_ms
);
loop {
for i in 0..1000 {
for i in 0..config.handlers.max_requests_per_iter {
let (request, src): (Request, SocketAddr) = if i == 0 {
match request_receiver.recv(){
Ok(r) => r,