use cistell_core::ConfigValue;
use rustvello_proto::config::{ArgumentPrintMode, LogFormat};
use super::{argument_print_mode_str, log_format_str, RustvelloBuilder};
pub struct LoggingBuilder {
parent: RustvelloBuilder,
}
impl LoggingBuilder {
pub(super) fn new(parent: RustvelloBuilder) -> Self {
Self { parent }
}
pub fn level(mut self, level: impl Into<String>) -> Self {
self.parent
.programmatic
.insert("logging_level", ConfigValue::String(level.into()));
self
}
pub fn format(mut self, format: LogFormat) -> Self {
let s = log_format_str(format);
self.parent
.programmatic
.insert("log_format", ConfigValue::String(s.to_string()));
self
}
pub fn use_colors(mut self, use_colors: Option<bool>) -> Self {
if let Some(b) = use_colors {
self.parent
.programmatic
.insert("log_use_colors", ConfigValue::Bool(b));
}
self
}
pub fn compact_context(mut self, compact: bool) -> Self {
self.parent
.programmatic
.insert("compact_log_context", ConfigValue::Bool(compact));
self
}
pub fn argument_print_mode(mut self, mode: ArgumentPrintMode) -> Self {
let s = argument_print_mode_str(mode);
self.parent
.programmatic
.insert("argument_print_mode", ConfigValue::String(s.to_string()));
self.parent
.programmatic
.insert("print_arguments", ConfigValue::Bool(true));
self
}
pub fn hide_arguments(mut self) -> Self {
self.parent
.programmatic
.insert("print_arguments", ConfigValue::Bool(false));
self
}
pub fn truncate_arguments_length(mut self, length: usize) -> Self {
self.parent.programmatic.insert(
"truncate_arguments_length",
ConfigValue::Integer(length as i64),
);
self
}
pub fn done(self) -> RustvelloBuilder {
self.parent
}
}
pub struct PerformanceBuilder {
parent: RustvelloBuilder,
}
impl PerformanceBuilder {
pub(super) fn new(parent: RustvelloBuilder) -> Self {
Self { parent }
}
pub fn cached_status_time(mut self, seconds: f64) -> Self {
self.parent
.programmatic
.insert("cached_status_time_seconds", ConfigValue::Float(seconds));
self
}
pub fn auto_final_invocation_purge_hours(mut self, hours: f64) -> Self {
self.parent.programmatic.insert(
"auto_final_invocation_purge_hours",
ConfigValue::Float(hours),
);
self
}
pub fn scheduler_interval(mut self, seconds: u64) -> Self {
self.parent.programmatic.insert(
"scheduler_interval_seconds",
ConfigValue::Integer(seconds as i64),
);
self
}
pub fn enable_scheduler(mut self, enabled: bool) -> Self {
self.parent
.programmatic
.insert("enable_scheduler", ConfigValue::Bool(enabled));
self
}
pub fn done(self) -> RustvelloBuilder {
self.parent
}
}
pub struct ReliabilityBuilder {
parent: RustvelloBuilder,
}
impl ReliabilityBuilder {
pub(super) fn new(parent: RustvelloBuilder) -> Self {
Self { parent }
}
pub fn max_pending_seconds(mut self, seconds: u64) -> Self {
self.parent
.programmatic
.insert("max_pending_seconds", ConfigValue::Integer(seconds as i64));
self
}
pub fn heartbeat_interval(mut self, seconds: u64) -> Self {
self.parent.programmatic.insert(
"heartbeat_interval_seconds",
ConfigValue::Integer(seconds as i64),
);
self
}
pub fn runner_dead_after(mut self, seconds: u64) -> Self {
self.parent.programmatic.insert(
"runner_dead_after_seconds",
ConfigValue::Integer(seconds as i64),
);
self
}
pub fn recovery_check_interval(mut self, seconds: u64) -> Self {
self.parent.programmatic.insert(
"recovery_check_interval_seconds",
ConfigValue::Integer(seconds as i64),
);
self
}
pub fn recover_pending_cron(mut self, cron: impl Into<String>) -> Self {
self.parent
.programmatic
.insert("recover_pending_cron", ConfigValue::String(cron.into()));
self
}
pub fn recover_running_cron(mut self, cron: impl Into<String>) -> Self {
self.parent
.programmatic
.insert("recover_running_cron", ConfigValue::String(cron.into()));
self
}
pub fn blocking_control(mut self, enabled: bool) -> Self {
self.parent
.programmatic
.insert("blocking_control", ConfigValue::Bool(enabled));
self
}
pub fn done(self) -> RustvelloBuilder {
self.parent
}
}