add default values
This commit is contained in:
parent
bee531ddca
commit
e69f3b54a9
3 changed files with 53 additions and 15 deletions
|
@ -112,13 +112,20 @@ pub struct Config {
|
|||
#[serde(default)]
|
||||
pub max_caption_length: MaxCommentLength,
|
||||
// pub disable_hsts: bool,
|
||||
pub cluster_limit: Option<u16>,
|
||||
// pub deliver_job_concurrency: u16,
|
||||
// pub inbox_job_concurrency: u16,
|
||||
// pub deliver_job_per_sec: u16,
|
||||
// pub inbox_job_per_sec: u16,
|
||||
// pub deliver_job_max_attempts: u16,
|
||||
// pub inbox_job_max_attempts: u16,
|
||||
#[serde(default = "cluster_limit_default")]
|
||||
pub cluster_limit: u16,
|
||||
#[serde(default = "deliver_job_default")]
|
||||
pub deliver_job_concurrency: u16,
|
||||
#[serde(default = "inbox_job_default")]
|
||||
pub inbox_job_concurrency: u16,
|
||||
#[serde(default = "deliver_job_default")]
|
||||
pub deliver_job_per_sec: u16,
|
||||
#[serde(default = "inbox_job_default")]
|
||||
pub inbox_job_per_sec: u16,
|
||||
#[serde(default = "deliver_job_attempts_default")]
|
||||
pub deliver_job_max_attempts: u16,
|
||||
#[serde(default = "inbox_job_attempts_default")]
|
||||
pub inbox_job_max_attempts: u16,
|
||||
// pub outgoing_address_family: IpFamily,
|
||||
// pub syslog: syslog::SyslogConfig,
|
||||
// pub proxy: Option<Host>,
|
||||
|
@ -182,6 +189,8 @@ pub mod db {
|
|||
|
||||
/// redis config
|
||||
pub mod redis {
|
||||
use url::Url;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
|
@ -196,6 +205,13 @@ pub mod redis {
|
|||
#[serde(default)]
|
||||
pub db: u8,
|
||||
}
|
||||
|
||||
impl From<&RedisConfig> for Url {
|
||||
fn from(value: &RedisConfig) -> Self {
|
||||
Url::parse(&format!("redis://{}:{}", value.host.1, value.port))
|
||||
.expect("Invalid redis host and port")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// sonic search config
|
||||
|
@ -270,6 +286,26 @@ impl Default for MaxCommentLength {
|
|||
}
|
||||
}
|
||||
|
||||
fn cluster_limit_default() -> u16 {
|
||||
1
|
||||
}
|
||||
|
||||
fn deliver_job_default() -> u16 {
|
||||
128
|
||||
}
|
||||
|
||||
fn deliver_job_attempts_default() -> u16 {
|
||||
12
|
||||
}
|
||||
|
||||
fn inbox_job_default() -> u16 {
|
||||
16
|
||||
}
|
||||
|
||||
fn inbox_job_attempts_default() -> u16 {
|
||||
8
|
||||
}
|
||||
|
||||
fn true_fn() -> bool {
|
||||
true
|
||||
}
|
||||
|
|
|
@ -123,8 +123,14 @@ redis:
|
|||
},
|
||||
max_note_length: MaxNoteLength(3000),
|
||||
max_caption_length: MaxCommentLength(1500),
|
||||
cluster_limit: None,
|
||||
cluster_limit: 1,
|
||||
env: Environment {},
|
||||
deliver_job_concurrency: 128,
|
||||
inbox_job_concurrency: 16,
|
||||
deliver_job_per_sec: 128,
|
||||
inbox_job_per_sec: 16,
|
||||
deliver_job_max_attempts: 12,
|
||||
inbox_job_max_attempts: 8,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,18 +17,14 @@ fn main() -> anyhow::Result<()> {
|
|||
);
|
||||
|
||||
// logging
|
||||
let is_debug = match env::var_os("NODE_ENV") {
|
||||
None => true,
|
||||
Some(val) => val != "production",
|
||||
};
|
||||
let subscriber = tracing_subscriber::fmt();
|
||||
if is_debug {
|
||||
if is_release!() {
|
||||
subscriber.with_max_level(tracing::Level::INFO).init();
|
||||
} else {
|
||||
subscriber
|
||||
.with_max_level(tracing::Level::DEBUG)
|
||||
.pretty()
|
||||
.init();
|
||||
} else {
|
||||
subscriber.with_max_level(tracing::Level::INFO).init();
|
||||
}
|
||||
|
||||
// bootstrap
|
||||
|
|
Loading…
Add table
Reference in a new issue