Change cluster_limit in config to an Option<usize>
This was originally a u16 (defaulting to 1) which is more similar to what the old backend config parsing used, but now if it's None tokio can automatically detect the number of worker threads to use based on the number of CPUs.
This commit is contained in:
parent
bdc391caa7
commit
fa63f01ffa
3 changed files with 4 additions and 5 deletions
|
@ -112,8 +112,7 @@ pub struct Config {
|
|||
#[serde(default)]
|
||||
pub max_caption_length: MaxCommentLength,
|
||||
// pub disable_hsts: bool,
|
||||
#[serde(default = "cluster_limit_default")]
|
||||
pub cluster_limit: u16,
|
||||
pub cluster_limit: Option<usize>,
|
||||
#[serde(default = "deliver_job_default")]
|
||||
pub deliver_job_concurrency: u16,
|
||||
#[serde(default = "inbox_job_default")]
|
||||
|
|
|
@ -43,7 +43,7 @@ pub fn get_config() -> Result<&'static Config, Error> {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
pub mod tests {
|
||||
use std::{
|
||||
fs::{remove_file, File},
|
||||
io::Write,
|
||||
|
@ -123,7 +123,7 @@ redis:
|
|||
},
|
||||
max_note_length: MaxNoteLength(3000),
|
||||
max_caption_length: MaxCommentLength(1500),
|
||||
cluster_limit: 1,
|
||||
cluster_limit: None,
|
||||
env: Environment {},
|
||||
deliver_job_concurrency: 128,
|
||||
inbox_job_concurrency: 16,
|
||||
|
|
|
@ -19,7 +19,7 @@ pub fn init() -> Result<(), Box<dyn error::Error>> {
|
|||
let rt = rt.enable_all();
|
||||
|
||||
if let Some(n) = get_config()?.cluster_limit {
|
||||
rt.worker_threads(n as usize);
|
||||
rt.worker_threads(n);
|
||||
}
|
||||
|
||||
let rt = rt.build()?;
|
||||
|
|
Loading…
Reference in a new issue