1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.

use serde::{Deserialize, Serialize};
use tikv_util::config::ReadableDuration;

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(default)]
#[serde(rename_all = "kebab-case")]
pub struct Config {
    pub max_batch_size: Option<usize>,
    pub pool_size: usize,
    pub reschedule_duration: ReadableDuration,
    pub low_priority_pool_size: usize,
}

impl Config {
    pub fn max_batch_size(&self) -> usize {
        // `Config::validate` is not called for test so the `max_batch_size` is None.
        self.max_batch_size.unwrap_or(256)
    }
}

impl Default for Config {
    fn default() -> Config {
        Config {
            max_batch_size: None,
            pool_size: 2,
            reschedule_duration: ReadableDuration::secs(5),
            low_priority_pool_size: 1,
        }
    }
}