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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//! # FluxMQ Core Library
//!
//! FluxMQ is a high-performance, Kafka-compatible message broker written in Rust.
//! This crate provides the core functionality for the FluxMQ message streaming platform.
//!
//! ## Features
//!
//! - **100% Kafka Compatibility**: Full wire protocol compatibility with Apache Kafka
//! - **Ultra-High Performance**: 601,379+ messages/second throughput with advanced optimizations
//! - **20 Kafka APIs**: Complete protocol implementation including produce, consume, and admin operations
//! - **Lock-Free Architecture**: Lock-free data structures with atomic operations for maximum performance
//! - **Sequential I/O**: Log-structured storage with memory-mapped I/O for 20-40x performance gains
//! - **SIMD Optimizations**: Hardware-accelerated processing with AVX2/SSE4.2 instructions
//! - **Enterprise Security**: TLS/SSL encryption, ACL authorization, SASL authentication
//! - **Consumer Groups**: Full coordination with partition assignment and rebalancing
//! - **Distributed Replication**: Leader-follower replication with Raft-like consensus
//!
//! ## Architecture Overview
//!
//! FluxMQ implements a modular architecture with the following core components:
//!
//! - [`broker`] - TCP server and request handling
//! - [`storage`] - Hybrid memory-disk storage with crash recovery
//! - [`protocol`] - Kafka wire protocol implementation
//! - [`consumer`] - Consumer group coordination
//! - [`replication`] - Data replication and consensus
//! - [`performance`] - Performance optimization modules
//! - [`metrics`] - Performance monitoring and metrics collection
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use fluxmq::{BrokerServer, BrokerConfig};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let config = BrokerConfig {
//! port: 9092,
//! host: "0.0.0.0".to_string(),
//! enable_consumer_groups: true,
//! ..Default::default()
//! };
//!
//! let server = BrokerServer::new(config).await?;
//! server.run().await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Performance Characteristics
//!
//! FluxMQ achieves exceptional performance through:
//!
//! - **MegaBatch Processing**: 1MB batches with LZ4 compression for maximum throughput
//! - **Zero-Copy Operations**: Direct memory mapping and `bytes::Bytes` for efficient I/O
//! - **Lock-Free Metrics**: Atomic counters with relaxed memory ordering (3,453% improvement)
//! - **Memory-Mapped Storage**: 256MB segments with sequential access patterns
//! - **Hardware Acceleration**: SIMD instructions for vectorized message processing
//!
//! ## Client Compatibility
//!
//! FluxMQ is compatible with all major Kafka client libraries:
//!
//! - **Java**: `org.apache.kafka:kafka-clients` v4.1+ (primary target)
//! - **Python**: `kafka-python` library
//! - **Scala**: Native Kafka Scala clients
//! - **Go**: `sarama` and `confluent-kafka-go`
//! - **Node.js**: `kafkajs` and `node-rdkafka`
pub use ;
pub use BrokerConfig;
pub use ;
pub use HttpMetricsServer;
pub use ;
pub use ;
pub use ;
pub use ;
use Error;
/// FluxMQ error types
///
/// This enum represents all possible error conditions that can occur within FluxMQ.
/// It provides detailed error information for debugging and error handling.
///
/// # Error Categories
///
/// - **Storage Errors**: File I/O, disk operations, and persistence failures
/// - **Network Errors**: TCP connection issues, protocol violations, and network timeouts
/// - **Serialization/Deserialization**: Binary encoding/decoding failures
/// - **Configuration**: Invalid configuration parameters or missing settings
/// - **Replication**: Leader-follower synchronization and consensus failures
/// - **Protocol**: Kafka wire protocol parsing and validation errors
///
/// # Example
///
/// ```rust,no_run
/// use fluxmq::{FluxmqError, Result};
///
/// fn handle_error(result: Result<()>) {
/// match result {
/// Ok(()) => println!("Success"),
/// Err(FluxmqError::Storage(e)) => println!("Storage error: {}", e),
/// Err(FluxmqError::Network(msg)) => println!("Network error: {}", msg),
/// Err(e) => println!("Other error: {}", e),
/// }
/// }
/// ```
/// Result type alias for FluxMQ operations
///
/// This is a convenience alias for `Result<T, FluxmqError>` used throughout
/// the FluxMQ codebase for consistent error handling.
///
/// # Example
///
/// ```rust,no_run
/// use fluxmq::Result;
///
/// fn process_message() -> Result<String> {
/// Ok("Message processed successfully".to_string())
/// }
/// ```
pub type Result<T> = Result;