Skip to content

Commit

Permalink
add fields and defaults to ServerConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Feb 2, 2024
1 parent 6d160b4 commit 62f3db3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
28 changes: 20 additions & 8 deletions command/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ pub const DEFAULT_WORKER_AUTOMATIC_RESTART: bool = true;
/// wether to save the state automatically (false)
pub const DEFAULT_AUTOMATIC_STATE_SAVE: bool = false;

/// minimum number of buffers (1)
pub const DEFAULT_MIN_BUFFERS: usize = 1;

/// maximum number of buffers (1 000)
pub const DEFAULT_MAX_BUFFERS: usize = 1_000;

Expand Down Expand Up @@ -1218,8 +1221,8 @@ impl ConfigBuilder {
.disable_cluster_metrics
.unwrap_or(DEFAULT_DISABLE_CLUSTER_METRICS),
min_buffers: std::cmp::min(
file_config.min_buffers.unwrap_or(1),
file_config.max_buffers.unwrap_or(1000),
file_config.min_buffers.unwrap_or(DEFAULT_MIN_BUFFERS),
file_config.max_buffers.unwrap_or(DEFAULT_MAX_BUFFERS),
),
pid_file_path: file_config.pid_file_path.clone(),
request_timeout: file_config
Expand Down Expand Up @@ -1751,6 +1754,9 @@ pub struct ServerConfig {
pub connect_timeout: u32,
pub zombie_check_interval: u32,
pub accept_queue_timeout: u32,
pub min_buffers: usize,
pub max_buffers: usize,
pub buffer_size: usize,
}

impl ServerConfig {
Expand All @@ -1762,6 +1768,9 @@ impl ServerConfig {
connect_timeout: config.connect_timeout,
zombie_check_interval: config.zombie_check_interval,
accept_queue_timeout: config.accept_queue_timeout,
min_buffers: config.min_buffers,
max_buffers: config.max_buffers,
buffer_size: config.buffer_size,
}
}

Expand All @@ -1774,12 +1783,15 @@ impl ServerConfig {
impl Default for ServerConfig {
fn default() -> ServerConfig {
ServerConfig {
max_connections: 10000,
front_timeout: 60,
back_timeout: 30,
connect_timeout: 3,
zombie_check_interval: 30 * 60,
accept_queue_timeout: 60,
max_connections: DEFAULT_MAX_CONNECTIONS,
front_timeout: DEFAULT_FRONT_TIMEOUT,
back_timeout: DEFAULT_BACK_TIMEOUT,
connect_timeout: DEFAULT_CONNECT_TIMEOUT,
zombie_check_interval: DEFAULT_ZOMBIE_CHECK_INTERVAL,
accept_queue_timeout: DEFAULT_ACCEPT_QUEUE_TIMEOUT,
min_buffers: DEFAULT_MIN_BUFFERS,
max_buffers: DEFAULT_MAX_BUFFERS,
buffer_size: DEFAULT_BUFFER_SIZE,
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@ impl Server {
expects_initial_status: bool,
) -> Result<Self, ServerError> {
let event_loop = Poll::new().map_err(ServerError::CreatePoll)?;
let server_config = ServerConfig::from_config(&config);
let pool = Rc::new(RefCell::new(Pool::with_capacity(
config.min_buffers,
config.max_buffers,
config.buffer_size,
server_config.min_buffers,
server_config.max_buffers,
server_config.buffer_size,
)));
let backends = Rc::new(RefCell::new(BackendMap::new()));
let server_config = ServerConfig::from_config(&config);

//FIXME: we will use a few entries for the channel, metrics socket and the listeners
//FIXME: for HTTP/2, we will have more than 2 entries per session
Expand Down

0 comments on commit 62f3db3

Please sign in to comment.