pub struct Config {
pub name: String,
pub logging: LogConfig,
pub shutdown: ShutdownConfig,
pub performance: PerformanceConfig,
pub monitoring: MonitoringConfig,
pub work_dir: Option<PathBuf>,
pub pid_file: Option<PathBuf>,
pub hot_reload: bool,
}
Expand description
Main daemon configuration.
Fields§
§name: String
Daemon name/identifier
logging: LogConfig
Logging configuration
shutdown: ShutdownConfig
Shutdown configuration
performance: PerformanceConfig
Performance configuration
monitoring: MonitoringConfig
Monitoring configuration
work_dir: Option<PathBuf>
Working directory
pid_file: Option<PathBuf>
PID file location
hot_reload: bool
Enable configuration hot-reloading
Implementations§
Source§impl Config
impl Config
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new config with defaults.
§Errors
Will return an error if the default configuration validation fails.
Sourcepub fn load() -> Result<Self>
pub fn load() -> Result<Self>
Load configuration from multiple sources with precedence:
- Default values
- Configuration file (if exists)
- Environment variables
- Provided overrides
§Errors
Will return an error if the configuration file cannot be read or contains invalid configuration data.
Sourcepub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
Load config from a file.
§Errors
Will return an error if the file cannot be read or contains invalid configuration data.
Sourcepub fn load_with_provider<P: Provider>(provider: P) -> Result<Self>
pub fn load_with_provider<P: Provider>(provider: P) -> Result<Self>
Load config using a configuration provider.
§Errors
Will return an error if the provider fails to load a valid configuration.
Sourcepub const fn shutdown_timeout(&self) -> Duration
pub const fn shutdown_timeout(&self) -> Duration
Get the shutdown timeout as a Duration.
Sourcepub const fn force_shutdown_timeout(&self) -> Duration
pub const fn force_shutdown_timeout(&self) -> Duration
Get the force shutdown timeout as a Duration.
Sourcepub const fn kill_timeout(&self) -> Duration
pub const fn kill_timeout(&self) -> Duration
Get the kill timeout as a Duration.
Sourcepub const fn metrics_interval(&self) -> Duration
pub const fn metrics_interval(&self) -> Duration
Get the metrics interval as a Duration.
Sourcepub const fn health_check_interval(&self) -> Duration
pub const fn health_check_interval(&self) -> Duration
Get the health check interval as a Duration.
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate the configuration.
§Errors
Will return an error if any configuration values are invalid or missing required fields.
Sourcepub fn worker_threads(&self) -> usize
pub fn worker_threads(&self) -> usize
Get the number of worker threads to use.
Sourcepub const fn is_json_logging(&self) -> bool
pub const fn is_json_logging(&self) -> bool
Check if JSON logging is enabled.
Sourcepub const fn is_colored_logging(&self) -> bool
pub const fn is_colored_logging(&self) -> bool
Check if colored logging is enabled.
Source§impl Config
impl Config
Sourcepub fn watch_file<F, P>(path: P, on_change: F) -> Result<RecommendedWatcher>
pub fn watch_file<F, P>(path: P, on_change: F) -> Result<RecommendedWatcher>
Start watching a configuration file and invoke a callback on changes.
This uses the same loading path as load_from_file
, so it will pick up
any enabled fast-paths (e.g., mmap-config
).
The returned watcher must be kept alive for notifications to continue.
§Errors
Returns an error if the watcher cannot be created or the path cannot be watched.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute
value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
Quirk
value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition
value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);