ncro/config: replace YAML configuration file with TOML
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ifb3cf9ad9747795b44eff1ee8cd538536a6a6964
This commit is contained in:
parent
56413f4b60
commit
49545fdb6b
20 changed files with 280 additions and 199 deletions
|
|
@ -1,13 +1,17 @@
|
|||
[package]
|
||||
name = "ncro-config"
|
||||
name = "ncro-config"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
hex.workspace = true
|
||||
hex.workspace = true
|
||||
humantime-serde.workspace = true
|
||||
serde = { workspace = true, features = [ "derive" ] }
|
||||
serde_yaml.workspace = true
|
||||
thiserror.workspace = true
|
||||
url.workspace = true
|
||||
serde = { workspace = true, features = [ "derive" ] }
|
||||
thiserror.workspace = true
|
||||
toml.workspace = true
|
||||
url.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ pub enum ConfigError {
|
|||
#[error("read config: {0}")]
|
||||
Read(#[from] std::io::Error),
|
||||
#[error("parse config: {0}")]
|
||||
Parse(#[from] serde_yaml::Error),
|
||||
Parse(#[from] toml::de::Error),
|
||||
#[error("{0}")]
|
||||
Validation(String),
|
||||
}
|
||||
|
|
@ -29,9 +29,9 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn parses_duration_yaml() -> Result<(), serde_yaml::Error> {
|
||||
let cfg: Config = serde_yaml::from_str(
|
||||
"server:\n read_timeout: 30s\ncache:\n ttl: 2h\n",
|
||||
fn parses_duration_toml() -> Result<(), toml::de::Error> {
|
||||
let cfg: Config = toml::from_str(
|
||||
"[server]\nread_timeout = \"30s\"\n\n[cache]\nttl = \"2h\"\n",
|
||||
)?;
|
||||
assert_eq!(cfg.server.read_timeout.0, Duration::from_secs(30));
|
||||
assert_eq!(cfg.cache.ttl.0, Duration::from_secs(7200));
|
||||
|
|
@ -207,7 +207,7 @@ impl Config {
|
|||
pub fn load(path: Option<&str>) -> Result<Self, ConfigError> {
|
||||
let mut cfg = if let Some(path) = path.filter(|p| !p.is_empty()) {
|
||||
let data = fs::read_to_string(path)?;
|
||||
serde_yaml::from_str::<Self>(&data)?
|
||||
toml::from_str::<Self>(&data)?
|
||||
} else {
|
||||
Self::default()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
[package]
|
||||
name = "ncro-db"
|
||||
name = "ncro-db"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
chrono = { workspace = true, features = [ "serde" ] }
|
||||
serde = { workspace = true, features = [ "derive" ] }
|
||||
sqlx = { workspace = true, features = [ "runtime-tokio-rustls", "sqlite", "macros", "migrate", "chrono" ] }
|
||||
chrono = { workspace = true, features = [ "serde" ] }
|
||||
serde = { workspace = true, features = [ "derive" ] }
|
||||
sqlx = { workspace = true, features = [ "runtime-tokio-rustls", "sqlite", "macros", "migrate", "chrono" ] }
|
||||
thiserror.workspace = true
|
||||
tokio = { workspace = true, features = [ "fs" ] }
|
||||
tokio = { workspace = true, features = [ "fs" ] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
[package]
|
||||
name = "ncro-discovery"
|
||||
name = "ncro-discovery"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
mdns-sd.workspace = true
|
||||
anyhow.workspace = true
|
||||
mdns-sd.workspace = true
|
||||
ncro-config.workspace = true
|
||||
ncro-health.workspace = true
|
||||
tokio = { workspace = true, features = [ "rt", "sync", "time" ] }
|
||||
tracing.workspace = true
|
||||
tokio = { workspace = true, features = [ "rt", "sync", "time" ] }
|
||||
tracing.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
[package]
|
||||
name = "ncro-health"
|
||||
name = "ncro-health"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
|
||||
[dependencies]
|
||||
ncro-config.workspace = true
|
||||
reqwest = { workspace = true, features = [ "rustls" ] }
|
||||
tokio = { workspace = true, features = [ "sync", "time", "rt" ] }
|
||||
reqwest = { workspace = true, features = [ "rustls" ] }
|
||||
tokio = { workspace = true, features = [ "sync", "time", "rt" ] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
[package]
|
||||
name = "ncro-mesh"
|
||||
name = "ncro-mesh"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
chrono.workspace = true
|
||||
ed25519-dalek = { workspace = true, features = [ "rand_core" ] }
|
||||
hex.workspace = true
|
||||
ncro-db.workspace = true
|
||||
rand.workspace = true
|
||||
chrono.workspace = true
|
||||
ed25519-dalek = { workspace = true, features = [ "rand_core" ] }
|
||||
hex.workspace = true
|
||||
ncro-db.workspace = true
|
||||
rand.workspace = true
|
||||
rmp-serde.workspace = true
|
||||
serde = { workspace = true, features = [ "derive" ] }
|
||||
serde = { workspace = true, features = [ "derive" ] }
|
||||
thiserror.workspace = true
|
||||
tokio = { workspace = true, features = [ "fs", "net", "rt", "sync", "time" ] }
|
||||
tracing.workspace = true
|
||||
tokio = { workspace = true, features = [ "fs", "net", "rt", "sync", "time" ] }
|
||||
tracing.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
[package]
|
||||
name = "ncro-metrics"
|
||||
name = "ncro-metrics"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
prometheus.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
[package]
|
||||
name = "ncro-narinfo"
|
||||
name = "ncro-narinfo"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
base64.workspace = true
|
||||
base64.workspace = true
|
||||
ed25519-dalek.workspace = true
|
||||
thiserror.workspace = true
|
||||
thiserror.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
ed25519-dalek = { workspace = true, features = [ "rand_core" ] }
|
||||
ed25519-dalek = { workspace = true, features = [ "rand_core" ] }
|
||||
rand.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
[package]
|
||||
name = "ncro-router"
|
||||
name = "ncro-router"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
chrono.workspace = true
|
||||
chrono.workspace = true
|
||||
futures-util.workspace = true
|
||||
ncro-db.workspace = true
|
||||
ncro-health.workspace = true
|
||||
ncro-db.workspace = true
|
||||
ncro-health.workspace = true
|
||||
ncro-metrics.workspace = true
|
||||
ncro-narinfo.workspace = true
|
||||
reqwest = { workspace = true, features = [ "rustls" ] }
|
||||
thiserror.workspace = true
|
||||
tokio = { workspace = true, features = [ "sync", "time", "rt" ] }
|
||||
tracing.workspace = true
|
||||
reqwest = { workspace = true, features = [ "rustls" ] }
|
||||
thiserror.workspace = true
|
||||
tokio = { workspace = true, features = [ "sync", "time", "rt" ] }
|
||||
tracing.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -1,18 +1,22 @@
|
|||
[package]
|
||||
name = "ncro-server"
|
||||
name = "ncro-server"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
axum = { workspace = true, features = [ "macros" ] }
|
||||
bytes.workspace = true
|
||||
axum = { workspace = true, features = [ "macros" ] }
|
||||
bytes.workspace = true
|
||||
futures-util.workspace = true
|
||||
ncro-config.workspace = true
|
||||
ncro-db.workspace = true
|
||||
ncro-health.workspace = true
|
||||
ncro-config.workspace = true
|
||||
ncro-db.workspace = true
|
||||
ncro-health.workspace = true
|
||||
ncro-metrics.workspace = true
|
||||
ncro-router.workspace = true
|
||||
reqwest = { workspace = true, features = [ "rustls", "stream" ] }
|
||||
serde = { workspace = true, features = [ "derive" ] }
|
||||
tracing.workspace = true
|
||||
ncro-router.workspace = true
|
||||
reqwest = { workspace = true, features = [ "rustls", "stream" ] }
|
||||
serde = { workspace = true, features = [ "derive" ] }
|
||||
tracing.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue