diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2020-05-09 16:40:10 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2020-05-09 16:40:10 +0200 |
commit | 79102ba463204721bccad8086a059adaf510c838 (patch) | |
tree | 476d3eea03daf62b017c65df23a51fbce6f5cf81 /src | |
parent | 154546a7b4eb36eb1e78fb814c5fe21c6030c2ee (diff) | |
download | diplonat-79102ba463204721bccad8086a059adaf510c838.tar.gz diplonat-79102ba463204721bccad8086a059adaf510c838.zip |
Consul URL is now a parameter
Diffstat (limited to 'src')
-rw-r--r-- | src/config.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs index 14d18be..efc0112 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,10 +1,11 @@ use std::env; -use anyhow::{Result, Context, anyhow}; +use anyhow::{Result, Context, Error, anyhow}; use log::*; pub struct DiplonatConfig { pub private_ip: String, pub consul_node_name: String, + pub consul_url: String, pub refresh_time: u32, pub expiration_time: u32 } @@ -14,8 +15,10 @@ pub fn load_env() -> Result<DiplonatConfig> { let ert = "DIPLONAT_REFRESH_TIME"; let eet = "DIPLONAT_EXPIRATION_TIME"; let ecnd = "DIPLONAT_CONSUL_NODE_NAME"; + let ecu = "DIPLONAT_CONSUL_URL"; let config = DiplonatConfig { + consul_url: match env::var(ecu) { Ok(e) => e, Err(_) => "http://127.0.0.1:8500".to_string() }, private_ip: env::var(epi) .with_context(|| format!("{} env var must be defined, eg: 192.168.0.18", epi))?, refresh_time: env::var(ert) @@ -34,6 +37,7 @@ pub fn load_env() -> Result<DiplonatConfig> { return Err(anyhow!("Expiration time (currently: {}s) must be twice bigger than refresh time (currently: {}s)", config.expiration_time, config.refresh_time)) } + info!("Consul URL: {}", config.consul_url); info!("Consul node name: {}", config.consul_node_name); info!("Private IP address: {}", config.private_ip); info!("Refresh time: {} seconds", config.refresh_time); |