use std::time::Duration;
#[derive(Debug, Clone)]
pub enum StreamingMode {
Batch,
Streaming,
StructuredStreaming { format: OutputFormat },
}
impl Default for StreamingMode {
fn default() -> Self {
Self::Batch
}
}
#[derive(Debug, Clone)]
pub enum OutputFormat {
PlainText,
JsonLines,
YamlStream,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StreamSource {
Stdout,
Stderr,
}
#[derive(Debug, Clone)]
pub struct BufferConfig {
pub line_buffer_size: usize,
pub max_lines: Option<usize>,
pub overflow_strategy: crate::subprocess::streaming::backpressure::OverflowStrategy,
pub block_timeout: Duration,
}
impl Default for BufferConfig {
fn default() -> Self {
Self {
line_buffer_size: 8192,
max_lines: Some(10000),
overflow_strategy:
crate::subprocess::streaming::backpressure::OverflowStrategy::DropOldest,
block_timeout: Duration::from_secs(5),
}
}
}
#[derive(Debug, Clone)]
pub struct StreamingConfig {
pub enabled: bool,
pub mode: StreamingMode,
pub buffer_config: BufferConfig,
pub processors: Vec<ProcessorConfig>,
}
impl Default for StreamingConfig {
fn default() -> Self {
Self {
enabled: false,
mode: StreamingMode::Batch,
buffer_config: BufferConfig::default(),
processors: Vec::new(),
}
}
}
#[derive(Debug, Clone)]
pub enum ProcessorConfig {
JsonLines { emit_events: bool },
PatternMatcher { patterns: Vec<regex::Regex> },
EventEmitter { event_type: String },
Custom { id: String },
}
#[derive(Debug)]
pub struct StreamingOutput {
pub status: std::process::ExitStatus,
pub stdout: Vec<String>,
pub stderr: Vec<String>,
pub duration: Duration,
}