Add WIP websocket to controller and refactor settings

This commit is contained in:
Tobias Reisinger 2023-11-23 16:00:24 +01:00
parent 452454f9e8
commit 32c75ad73a
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
11 changed files with 128 additions and 37 deletions
emgauwa-controller/src

View file

@ -1,5 +1,4 @@
use config::Config;
use emgauwa_lib::constants;
use emgauwa_lib::{constants, utils};
use serde_derive::Deserialize;
#[derive(Clone, Debug, Deserialize)]
@ -22,6 +21,7 @@ pub struct Logging {
#[serde(default)]
#[allow(unused)]
pub struct Settings {
pub core: Core,
pub database: String,
pub logging: Logging,
}
@ -29,6 +29,7 @@ pub struct Settings {
impl Default for Settings {
fn default() -> Self {
Settings {
core: Core::default(),
database: String::from("sqlite://emgauwa-controller.sqlite"),
logging: Logging::default(),
}
@ -54,15 +55,5 @@ impl Default for Logging {
}
pub fn init() -> Settings {
Config::builder()
.add_source(config::File::with_name("emgauwa-controller"))
.add_source(
config::Environment::with_prefix("EMGAUWA_CONTROLLER")
.prefix_separator("_")
.separator("__"),
)
.build()
.unwrap()
.try_deserialize::<Settings>()
.unwrap_or_else(|_| panic!("Error reading settings."))
utils::load_settings("controller", "CONTROLLER")
}