1#![allow(clippy::disallowed_types)] use std::collections::HashMap;
5use std::path::PathBuf;
6
7use laminar_connectors::connector::DeliveryGuarantee;
8use laminar_core::streaming::{BackpressureStrategy, StreamCheckpointConfig};
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
12pub enum BackpressurePolicy {
13 #[default]
15 Backpressure,
16 ShedOldest,
18 Fail,
20}
21
22#[derive(Clone)]
24pub struct SecretString(String);
25
26impl SecretString {
27 pub fn new(value: impl Into<String>) -> Self {
29 Self(value.into())
30 }
31
32 #[must_use]
34 pub fn expose(&self) -> &str {
35 &self.0
36 }
37}
38
39impl std::fmt::Debug for SecretString {
40 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
41 f.write_str("\"[REDACTED]\"")
42 }
43}
44
45#[derive(Debug, Clone)]
47pub struct RestartPolicy {
48 pub max_restarts: usize,
50 pub window: std::time::Duration,
52 pub initial_backoff: std::time::Duration,
54 pub max_backoff: std::time::Duration,
56}
57
58impl Default for RestartPolicy {
59 fn default() -> Self {
60 Self {
61 max_restarts: 5,
62 window: std::time::Duration::from_secs(60),
63 initial_backoff: std::time::Duration::from_millis(500),
64 max_backoff: std::time::Duration::from_secs(30),
65 }
66 }
67}
68
69#[derive(Debug, Clone)]
71pub struct LaminarConfig {
72 pub default_buffer_size: usize,
74 pub default_backpressure: BackpressureStrategy,
76 pub storage_dir: Option<PathBuf>,
78 pub checkpoint: Option<StreamCheckpointConfig>,
80 pub incremental_emit: bool,
83 pub object_store_url: Option<String>,
85 pub object_store_options: HashMap<String, String>,
87 pub http_auth_token: Option<SecretString>,
90 pub delivery_guarantee: DeliveryGuarantee,
92 pub pipeline_channel_capacity: Option<usize>,
94 pub pipeline_batch_window: Option<std::time::Duration>,
96 pub pipeline_drain_budget_ns: Option<u64>,
98 pub pipeline_query_budget_ns: Option<u64>,
100 pub pipeline_max_input_buf_batches: Option<usize>,
102 pub pipeline_max_input_buf_bytes: Option<usize>,
104 pub pipeline_backpressure_policy: BackpressurePolicy,
106 pub restart_policy: RestartPolicy,
108 pub shared_source_isolation: bool,
111}
112
113impl Default for LaminarConfig {
114 fn default() -> Self {
115 Self {
116 default_buffer_size: 65536,
117 default_backpressure: BackpressureStrategy::Block,
118 storage_dir: None,
119 checkpoint: None,
120 incremental_emit: true,
121 object_store_url: None,
122 object_store_options: HashMap::new(),
123 http_auth_token: None,
124 delivery_guarantee: DeliveryGuarantee::default(),
125 pipeline_channel_capacity: None,
126 pipeline_batch_window: None,
127 pipeline_drain_budget_ns: None,
128 pipeline_query_budget_ns: None,
129 pipeline_max_input_buf_batches: None,
130 pipeline_max_input_buf_bytes: None,
131 pipeline_backpressure_policy: BackpressurePolicy::default(),
132 restart_policy: RestartPolicy::default(),
133 shared_source_isolation: false,
134 }
135 }
136}