1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//! Kafka integration for stream processing
//!
//! This module provides Kafka source and sink implementations for ingesting
//! and producing events in the stream processing pipeline.
//!
//! # Features
//!
//! ## KafkaSource (Consumer)
//! - Robust Kafka consumer with metrics and offset management
//! - Automatic reconnection on errors
//! - Configurable commit strategies (auto, manual, periodic, on-checkpoint)
//! - Multiple partition support with rebalancing
//! - Graceful shutdown handling
//! - Message deserialization with error handling
//! - Comprehensive metrics tracking (throughput, lag, etc.)
//!
//! ## KafkaSink (Producer)
//! - High-performance Kafka producer with batching and compression
//! - Idempotent producer support
//! - Transactional support for exactly-once semantics
//! - Circuit breaker for fault tolerance
//! - Retry logic with exponential backoff
//! - Configurable partitioning strategies
//! - Comprehensive metrics tracking (latency, throughput, errors)
//!
//! ## Configuration
//! - Comprehensive configuration types for source and sink
//! - Support for all rdkafka settings
//! - Security configuration (SASL, SSL)
//! - Performance tuning options
//!
//! ## Error Handling
//! - Kafka-specific error types with proper context
//! - Error severity levels for monitoring
//! - Retryable vs fatal error classification
//!
//! # Example: Source Usage
//!
//! ```rust,no_run
//! use processor::kafka::{KafkaSource, KafkaSourceConfig, CommitStrategy};
//! use serde::{Deserialize, Serialize};
//! use tokio::sync::mpsc;
//!
//! #[derive(Clone, Debug, Serialize, Deserialize)]
//! struct MyEvent {
//! value: f64,
//! timestamp: i64,
//! }
//!
//! # async fn example() -> anyhow::Result<()> {
//! // Configure Kafka source
//! let config = KafkaSourceConfig {
//! brokers: "localhost:9092".to_string(),
//! group_id: "my-consumer-group".to_string(),
//! topics: vec!["my-topic".to_string()],
//! commit_strategy: CommitStrategy::Periodic,
//! commit_interval_secs: Some(5),
//! ..Default::default()
//! };
//!
//! // Create Kafka source
//! let source = KafkaSource::<MyEvent>::new(config, None).await?;
//!
//! // Create channel for messages
//! let (tx, mut rx) = mpsc::channel(1000);
//!
//! // Start consuming in background
//! let source_handle = tokio::spawn(async move {
//! source.start(tx).await
//! });
//!
//! // Process messages
//! while let Some(msg) = rx.recv().await {
//! println!("Received: {:?}", msg.payload);
//! }
//!
//! # Ok(())
//! # }
//! ```
//!
//! # Example: Sink Usage
//!
//! ```rust,no_run
//! use processor::kafka::{KafkaSink, KafkaSinkConfig, KafkaMessage};
//! use serde::{Deserialize, Serialize};
//!
//! #[derive(Clone, Debug, Serialize, Deserialize)]
//! struct MetricResult {
//! avg_latency: f64,
//! count: u64,
//! }
//!
//! # async fn example() -> anyhow::Result<()> {
//! let config = KafkaSinkConfig {
//! brokers: "localhost:9092".to_string(),
//! topic: "results".to_string(),
//! enable_idempotence: true,
//! ..Default::default()
//! };
//!
//! let sink = KafkaSink::<MetricResult>::new(config).await?;
//!
//! let message = KafkaMessage::new(MetricResult {
//! avg_latency: 123.45,
//! count: 1000,
//! }).with_key("service-a".to_string());
//!
//! sink.send(message).await?;
//! sink.close().await?;
//! # Ok(())
//! # }
//! ```
// Re-export config types
pub use ;
// Re-export error types
pub use ;
// Re-export offset manager types
pub use ;
// Re-export source types
pub use ;
// Re-export sink types
pub use ;
// Re-export integration types
pub use ;