use std::time::Duration;
pub struct ApplicationConfig {
#[cfg(feature = "tracing")]
pub(crate) tracing_subscribe: bool,
#[cfg(feature = "tracing")]
pub(crate) tracing_panics: bool,
pub(crate) graceful_shutdown: bool,
pub(crate) graceful_shutdown_timeout: Duration,
}
impl ApplicationConfig {
pub const fn new() -> Self {
Self {
#[cfg(feature = "tracing")]
tracing_subscribe: false,
#[cfg(feature = "tracing")]
tracing_panics: false,
graceful_shutdown: false,
graceful_shutdown_timeout: Duration::from_secs(10),
}
}
#[cfg(feature = "tracing")]
pub fn with_tracing_subscribe(mut self, value: bool) -> Self {
self.tracing_subscribe = value;
self
}
#[cfg(feature = "tracing")]
pub fn with_tracing_panics(mut self, value: bool) -> Self {
self.tracing_panics = value;
self
}
pub fn with_graceful_shutdown(mut self, value: bool) -> Self {
self.graceful_shutdown = value;
self
}
pub fn with_graceful_shutdown_timeout(mut self, duration: Duration) -> Self {
self.graceful_shutdown_timeout = duration;
self
}
}
impl Default for ApplicationConfig {
fn default() -> Self {
Self {
#[cfg(feature = "tracing")]
tracing_subscribe: true,
#[cfg(feature = "tracing")]
tracing_panics: true,
graceful_shutdown: true,
graceful_shutdown_timeout: Duration::from_secs(10),
}
}
}