Skip to main content

azoth_bus/
config.rs

1use serde::{Deserialize, Serialize};
2
3/// Configuration for a stream
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct StreamConfig {
6    /// Stream name
7    pub name: String,
8
9    /// Optional retention policy
10    pub retention: Option<RetentionPolicy>,
11}
12
13/// Retention policy for events in a stream
14#[derive(Debug, Clone, Serialize, Deserialize)]
15pub enum RetentionPolicy {
16    /// Keep all events (no cleanup)
17    KeepAll,
18
19    /// Keep events for N days
20    KeepDays(u64),
21
22    /// Keep last N events
23    KeepCount(u64),
24}
25
26/// Metadata stored for each consumer
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct ConsumerMetadata {
29    /// Consumer name
30    pub name: String,
31
32    /// Stream name
33    pub stream: String,
34
35    /// When consumer was created
36    pub created_at: chrono::DateTime<chrono::Utc>,
37
38    /// Last acknowledgment timestamp
39    pub last_ack_at: Option<chrono::DateTime<chrono::Utc>>,
40}
41
42impl ConsumerMetadata {
43    pub fn new(stream: String, name: String) -> Self {
44        Self {
45            name,
46            stream,
47            created_at: chrono::Utc::now(),
48            last_ack_at: None,
49        }
50    }
51}