update
This commit is contained in:
@@ -8,6 +8,9 @@ pub struct Config {
|
||||
pub server: ServerConfig,
|
||||
pub storage: StorageConfig,
|
||||
pub queue: QueueConfig,
|
||||
pub api_server: Option<ApiServerConfig>,
|
||||
#[serde(default)]
|
||||
pub old_db: Option<OldDbConfig>,
|
||||
}
|
||||
|
||||
|
||||
@@ -35,15 +38,31 @@ pub struct QueueConfig {
|
||||
pub idle_request_rate_threshold: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct ApiServerConfig {
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct OldDbConfig {
|
||||
pub path: String,
|
||||
#[serde(default = "default_auto_migrate")]
|
||||
pub auto_migrate: bool,
|
||||
}
|
||||
|
||||
fn default_auto_migrate() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn load() -> Result<Self, config::ConfigError> {
|
||||
let config = config::Config::builder()
|
||||
.add_source(config::File::with_name("config"))
|
||||
.build()?;
|
||||
|
||||
|
||||
config.try_deserialize()
|
||||
}
|
||||
|
||||
|
||||
pub fn server_address(&self) -> String {
|
||||
format!("{}:{}", self.server.host, self.server.port)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user