azoth_core/config/
projector.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct ProjectorConfig {
6 #[serde(default = "default_batch_events_max")]
9 pub batch_events_max: usize,
10
11 #[serde(default = "default_batch_bytes_max")]
14 pub batch_bytes_max: usize,
15
16 #[serde(default = "default_max_apply_latency_ms")]
20 pub max_apply_latency_ms: u64,
21
22 #[serde(default = "default_poll_interval_ms")]
25 pub poll_interval_ms: u64,
26
27 #[serde(default = "default_max_lag_before_throttle")]
30 pub max_lag_before_throttle: u64,
31}
32
33fn default_batch_events_max() -> usize {
34 1000
35}
36
37fn default_batch_bytes_max() -> usize {
38 4 * 1024 * 1024 }
40
41fn default_max_apply_latency_ms() -> u64 {
42 100
43}
44
45fn default_poll_interval_ms() -> u64 {
46 10
47}
48
49fn default_max_lag_before_throttle() -> u64 {
50 100_000
51}
52
53impl Default for ProjectorConfig {
54 fn default() -> Self {
55 Self {
56 batch_events_max: default_batch_events_max(),
57 batch_bytes_max: default_batch_bytes_max(),
58 max_apply_latency_ms: default_max_apply_latency_ms(),
59 poll_interval_ms: default_poll_interval_ms(),
60 max_lag_before_throttle: default_max_lag_before_throttle(),
61 }
62 }
63}
64
65impl ProjectorConfig {
66 pub fn new() -> Self {
67 Self::default()
68 }
69
70 pub fn with_batch_events_max(mut self, max: usize) -> Self {
71 self.batch_events_max = max;
72 self
73 }
74
75 pub fn with_batch_bytes_max(mut self, max: usize) -> Self {
76 self.batch_bytes_max = max;
77 self
78 }
79
80 pub fn with_max_apply_latency_ms(mut self, ms: u64) -> Self {
81 self.max_apply_latency_ms = ms;
82 self
83 }
84}