prodigy/subprocess/streaming/
types.rs1use std::time::Duration;
4
5#[derive(Debug, Clone)]
7pub enum StreamingMode {
8 Batch,
10 Streaming,
12 StructuredStreaming { format: OutputFormat },
14}
15
16impl Default for StreamingMode {
17 fn default() -> Self {
18 Self::Batch
19 }
20}
21
22#[derive(Debug, Clone)]
24pub enum OutputFormat {
25 PlainText,
26 JsonLines,
27 YamlStream,
28}
29
30#[derive(Debug, Clone, Copy, PartialEq, Eq)]
32pub enum StreamSource {
33 Stdout,
34 Stderr,
35}
36
37#[derive(Debug, Clone)]
39pub struct BufferConfig {
40 pub line_buffer_size: usize,
42 pub max_lines: Option<usize>,
44 pub overflow_strategy: crate::subprocess::streaming::backpressure::OverflowStrategy,
46 pub block_timeout: Duration,
48}
49
50impl Default for BufferConfig {
51 fn default() -> Self {
52 Self {
53 line_buffer_size: 8192,
54 max_lines: Some(10000),
55 overflow_strategy:
56 crate::subprocess::streaming::backpressure::OverflowStrategy::DropOldest,
57 block_timeout: Duration::from_secs(5),
58 }
59 }
60}
61
62#[derive(Debug, Clone)]
64pub struct StreamingConfig {
65 pub enabled: bool,
67 pub mode: StreamingMode,
69 pub buffer_config: BufferConfig,
71 pub processors: Vec<ProcessorConfig>,
73}
74
75impl Default for StreamingConfig {
76 fn default() -> Self {
77 Self {
78 enabled: false,
79 mode: StreamingMode::Batch,
80 buffer_config: BufferConfig::default(),
81 processors: Vec::new(),
82 }
83 }
84}
85
86#[derive(Debug, Clone)]
88pub enum ProcessorConfig {
89 JsonLines { emit_events: bool },
91 PatternMatcher { patterns: Vec<regex::Regex> },
93 EventEmitter { event_type: String },
95 Custom { id: String },
97}
98
99#[derive(Debug)]
101pub struct StreamingOutput {
102 pub status: std::process::ExitStatus,
104 pub stdout: Vec<String>,
106 pub stderr: Vec<String>,
108 pub duration: Duration,
110}