common/
config.rs

1//! Configuration types for runtime and execution settings
2
3/// Runtime configuration for tokio and thread pools
4#[derive(Debug, Clone, Copy, Default)]
5pub struct RuntimeConfig {
6    /// Number of worker threads (0 = number of CPU cores)
7    pub max_workers: usize,
8    /// Number of blocking threads (0 = tokio default of 512)
9    pub max_blocking_threads: usize,
10}
11
12/// Throttling configuration for resource control
13#[derive(Debug, Clone, Copy, Default)]
14pub struct ThrottleConfig {
15    /// Maximum number of open files (None = 80% of system limit)
16    pub max_open_files: Option<usize>,
17    /// Operations per second throttle (0 = no throttle)
18    pub ops_throttle: usize,
19    /// I/O operations per second throttle (0 = no throttle)
20    pub iops_throttle: usize,
21    /// Chunk size for I/O operations (bytes)
22    pub chunk_size: u64,
23}
24
25impl ThrottleConfig {
26    /// Validate configuration and return errors if invalid
27    pub fn validate(&self) -> Result<(), String> {
28        if self.iops_throttle > 0 && self.chunk_size == 0 {
29            return Err("chunk_size must be specified when using iops_throttle".to_string());
30        }
31        Ok(())
32    }
33}
34
35/// Output and logging configuration
36#[derive(Debug, Clone, Copy, Default)]
37pub struct OutputConfig {
38    /// Suppress error output
39    pub quiet: bool,
40    /// Verbosity level: 0=ERROR, 1=INFO, 2=DEBUG, 3=TRACE
41    pub verbose: u8,
42    /// Print summary statistics at the end
43    pub print_summary: bool,
44}
45
46/// Tracing configuration for debugging and profiling
47#[derive(Debug)]
48pub struct TracingConfig {
49    /// Remote tracing layer for distributed tracing
50    pub remote_layer: Option<crate::remote_tracing::RemoteTracingLayer>,
51    /// Debug log file path
52    pub debug_log_file: Option<String>,
53    /// Chrome trace output prefix (produces JSON viewable in Perfetto UI)
54    pub chrome_trace_prefix: Option<String>,
55    /// Flamegraph output prefix (produces folded stacks for inferno)
56    pub flamegraph_prefix: Option<String>,
57    /// Identifier for trace filenames (e.g., "rcp-master", "rcpd-source", "rcpd-destination")
58    pub trace_identifier: String,
59    /// Log level for profiling layers (chrome trace, flamegraph)
60    /// Defaults to "trace" when profiling is enabled
61    pub profile_level: Option<String>,
62    /// Enable tokio-console for live async debugging
63    pub tokio_console: bool,
64    /// Port for tokio-console server (default: 6669)
65    pub tokio_console_port: Option<u16>,
66}
67
68impl Default for TracingConfig {
69    fn default() -> Self {
70        Self {
71            remote_layer: None,
72            debug_log_file: None,
73            chrome_trace_prefix: None,
74            flamegraph_prefix: None,
75            trace_identifier: "unknown".to_string(),
76            profile_level: None,
77            tokio_console: false,
78            tokio_console_port: None,
79        }
80    }
81}