Correctly initialize [server].bind & [metrics].bind
Some checks failed
build / binary (push) Has been cancelled
build / binary-static (x86_64-linux) (push) Has been cancelled
build / clippy (push) Has been cancelled
lint / linting (push) Has been cancelled
build / container (push) Has been cancelled

Fixes #10.

Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
This commit is contained in:
Gergely Nagy 2025-03-05 11:57:08 +01:00
parent 2bfc4c81a8
commit e34e81cf10
No known key found for this signature in database
2 changed files with 25 additions and 2 deletions

View file

@ -12,6 +12,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- Implemented a new metric, `iocaine_maze_depth`, a counter to track how deep the maze has been explored so far. - Implemented a new metric, `iocaine_maze_depth`, a counter to track how deep the maze has been explored so far.
- When metrics are enabled, process metrics such as CPU seconds used, memory usage, etc, are also emitted. - When metrics are enabled, process metrics such as CPU seconds used, memory usage, etc, are also emitted.
### Fixed
- The default bind address, both for the main service, and for metrics, are now correctly initialized with a default.
## [1.0.0] - 2025-03-01 ## [1.0.0] - 2025-03-01
_Initial release._ _Initial release._

View file

@ -19,13 +19,13 @@ pub struct Config {
pub metrics: MetricsConfig, pub metrics: MetricsConfig,
} }
#[derive(Clone, Debug, Deserialize, Default)] #[derive(Clone, Debug, Deserialize)]
pub struct ServerConfig { pub struct ServerConfig {
#[serde(default = "ServerConfig::default_bind")] #[serde(default = "ServerConfig::default_bind")]
pub bind: String, pub bind: String,
} }
#[derive(Clone, Debug, Deserialize, Default)] #[derive(Clone, Debug, Deserialize)]
pub struct MetricsConfig { pub struct MetricsConfig {
#[serde(default)] #[serde(default)]
pub enable: bool, pub enable: bool,
@ -43,6 +43,17 @@ impl MetricsConfig {
} }
} }
impl Default for MetricsConfig {
fn default() -> Self {
Self {
enable: Default::default(),
labels: Default::default(),
bind: Self::default_bind(),
agent_group: Default::default(),
}
}
}
#[derive(Clone, Debug, Deserialize, PartialEq)] #[derive(Clone, Debug, Deserialize, PartialEq)]
pub enum MetricsLabel { pub enum MetricsLabel {
Host, Host,
@ -63,6 +74,14 @@ impl ServerConfig {
} }
} }
impl Default for ServerConfig {
fn default() -> Self {
Self {
bind: Self::default_bind(),
}
}
}
#[derive(Clone, Debug, Deserialize)] #[derive(Clone, Debug, Deserialize)]
pub struct SourceConfig { pub struct SourceConfig {
pub markov: Vec<String>, pub markov: Vec<String>,