From f13f870a92b806a3a60fd97c858a1be98ac009e6 Mon Sep 17 00:00:00 2001 From: "Aode (Lion)" Date: Mon, 21 Mar 2022 22:05:32 -0500 Subject: [PATCH] Only use console config when console feature is enabled --- src/config.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 5f58098..3d43ad2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -82,6 +82,7 @@ pub(crate) struct Overrides { #[serde(skip_serializing_if = "Option::is_none")] sled_cache_capacity: Option, + #[cfg(feature = "console")] #[structopt( long, help = "Specify the number of events the console subscriber is allowed to buffer" @@ -121,11 +122,19 @@ impl Overrides { && self.max_image_height.is_none() && self.max_image_area.is_none() && self.sled_cache_capacity.is_none() - && self.console_buffer_capacity.is_none() + && self.default_console_settings() && self.api_key.is_none() && self.opentelemetry_url.is_none() && self.store.is_none() } + + fn default_console_settings(&self) -> bool { + #[cfg(feature = "console")] + return self.console_buffer_capacity.is_none(); + + #[cfg(not(feature = "console"))] + true + } } #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] @@ -200,6 +209,7 @@ pub(crate) struct Config { max_image_height: usize, max_image_area: usize, sled_cache_capacity: u64, + #[cfg(feature = "console")] console_buffer_capacity: usize, api_key: Option, opentelemetry_url: Option, @@ -216,6 +226,7 @@ pub(crate) struct Defaults { max_image_height: usize, max_image_area: usize, sled_cache_capacity: u64, + #[cfg(feature = "console")] console_buffer_capacity: usize, store: Store, } @@ -230,6 +241,7 @@ impl Defaults { max_image_height: 10_000, max_image_area: 40_000_000, sled_cache_capacity: 1024 * 1024 * 64, // 16 times smaller than sled's default of 1GB + #[cfg(feature = "console")] console_buffer_capacity: 1024 * 128, store: Store::FileStore { path: None }, }