mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 02:35:31 +00:00
udp: only include prometheus fields in config if feature enabled
This commit is contained in:
parent
9bd4062e44
commit
3806faaff9
3 changed files with 41 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use std::{net::SocketAddr, path::PathBuf};
|
||||
|
||||
use aquatic_common::{access_list::AccessListConfig, privileges::PrivilegeConfig};
|
||||
use cfg_if::cfg_if;
|
||||
use serde::Deserialize;
|
||||
|
||||
use aquatic_common::cli::LogLevel;
|
||||
|
|
@ -154,15 +155,25 @@ pub struct StatisticsConfig {
|
|||
/// Path to save HTML file to
|
||||
pub html_file_path: PathBuf,
|
||||
/// Run a prometheus endpoint
|
||||
#[cfg(feature = "prometheus")]
|
||||
pub run_prometheus_endpoint: bool,
|
||||
/// Address to run prometheus endpoint on
|
||||
#[cfg(feature = "prometheus")]
|
||||
pub prometheus_endpoint_address: SocketAddr,
|
||||
}
|
||||
|
||||
impl StatisticsConfig {
|
||||
pub fn active(&self) -> bool {
|
||||
(self.interval != 0)
|
||||
& (self.print_to_stdout | self.write_html_to_file | self.run_prometheus_endpoint)
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "prometheus")] {
|
||||
pub fn active(&self) -> bool {
|
||||
(self.interval != 0) &
|
||||
(self.print_to_stdout | self.write_html_to_file | self.run_prometheus_endpoint)
|
||||
}
|
||||
} else {
|
||||
pub fn active(&self) -> bool {
|
||||
(self.interval != 0) & (self.print_to_stdout | self.write_html_to_file)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +185,9 @@ impl Default for StatisticsConfig {
|
|||
print_to_stdout: false,
|
||||
write_html_to_file: false,
|
||||
html_file_path: "tmp/statistics.html".into(),
|
||||
#[cfg(feature = "prometheus")]
|
||||
run_prometheus_endpoint: false,
|
||||
#[cfg(feature = "prometheus")]
|
||||
prometheus_endpoint_address: SocketAddr::from(([0, 0, 0, 0], 9000)),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue