Skip to content

Commit fc92391

Browse files
committed
Improve configuration defaults.
1 parent 8e85731 commit fc92391

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/config.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use serde::Deserialize;
55

66
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
77

8-
#[derive(Deserialize, Default)]
8+
#[derive(Deserialize)]
9+
#[serde(default)]
910
pub struct UdpForwarder {
1011
pub log_level: String,
1112
#[serde(default)]
@@ -14,7 +15,19 @@ pub struct UdpForwarder {
1415
pub servers: Vec<Server>,
1516
}
1617

18+
impl Default for UdpForwarder {
19+
fn default() -> Self {
20+
UdpForwarder {
21+
log_level: "INFO".to_string(),
22+
log_to_syslog: false,
23+
metrics_bind: "".to_string(),
24+
servers: vec![],
25+
}
26+
}
27+
}
28+
1729
#[derive(Deserialize)]
30+
#[serde(default)]
1831
pub struct Server {
1932
pub server: String,
2033
pub keepalive_interval_secs: u64,
@@ -37,12 +50,22 @@ impl Default for Server {
3750
}
3851
}
3952

40-
#[derive(Deserialize, Default)]
53+
#[derive(Deserialize)]
54+
#[serde(default)]
4155
pub struct Concentratord {
4256
pub event_url: String,
4357
pub command_url: String,
4458
}
4559

60+
impl Default for Concentratord {
61+
fn default() -> Self {
62+
Concentratord {
63+
event_url: "ipc:///tmp/concentratord_event".to_string(),
64+
command_url: "ipc:///tmp/concentratord_command".to_string(),
65+
}
66+
}
67+
}
68+
4669
#[derive(Deserialize)]
4770
pub struct Configuration {
4871
pub udp_forwarder: UdpForwarder,

0 commit comments

Comments
 (0)