Delete src/config.rs
This commit is contained in:
parent
0dcc6de7b8
commit
fe3d69d8f0
@ -1,36 +0,0 @@
|
||||
use serde::Deserialize;
|
||||
use std::path::PathBuf;
|
||||
use config::ConfigError;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct ServerConfig {
|
||||
pub port: u16,
|
||||
pub log_path: PathBuf,
|
||||
pub cluster_mode: bool,
|
||||
pub redis_nodes: Vec<String>,
|
||||
}
|
||||
|
||||
impl Default for ServerConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
port: 6379,
|
||||
log_path: "futriix.log".into(),
|
||||
cluster_mode: false,
|
||||
redis_nodes: vec!["redis://127.0.0.1:6379".to_string()],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ServerConfig {
|
||||
pub fn load() -> Result<Self, ConfigError> {
|
||||
let mut builder = config::Config::builder()
|
||||
.set_default("port", 6379)?
|
||||
.set_default("log_path", "futriix.log")?
|
||||
.set_default("cluster_mode", false)?
|
||||
.set_default("redis_nodes", vec!["redis://127.0.0.1:6379"])?;
|
||||
|
||||
builder = builder.add_source(config::File::with_name("futriix").required(false));
|
||||
|
||||
builder.build()?.try_deserialize()
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user