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
//! # rivven-client
//!
//! Native async Rust client library for [Rivven](https://rivven.hupe1980.github.io/rivven/),
//! the high-performance, single-binary event streaming platform.
//!
//! ## Features
//!
//! - **Async/Await**: Built on Tokio for high-performance async I/O
//! - **Connection Pooling**: Efficient connection management with [`ResilientClient`]
//! - **Circuit Breaker**: Automatic failure detection and recovery
//! - **Automatic Retries**: Exponential backoff with configurable limits
//! - **Multi-Server Failover**: Bootstrap server list with automatic failover
//! - **SCRAM-SHA-256 Authentication**: Secure password-based authentication
//! - **TLS Support**: Optional TLS encryption (requires `tls` feature)
//!
//! ## Quick Start
//!
//! ```rust,ignore
//! use rivven_client::{ResilientClient, ResilientClientConfig};
//!
//! # async fn example() -> rivven_client::Result<()> {
//! // Create a client with connection pooling and circuit breaker
//! let config = ResilientClientConfig::builder()
//! .servers(vec!["127.0.0.1:9092".to_string()])
//! .max_connections(10)
//! .build()?;
//!
//! let client = ResilientClient::new(config).await?;
//!
//! // Publish a message
//! client.publish("my-topic", b"Hello, Rivven!").await?;
//!
//! // Consume messages
//! let messages = client.consume("my-topic", 0, 0, 100).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Authentication
//!
//! The client supports SCRAM-SHA-256 authentication:
//!
//! ```rust,no_run
//! use rivven_client::{Client, AuthSession};
//!
//! # async fn example() -> rivven_client::Result<()> {
//! let mut client = Client::connect("127.0.0.1:9092").await?;
//!
//! // Authenticate with SCRAM-SHA-256
//! client.authenticate_scram("username", "password").await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Resilient Client
//!
//! For production use, [`ResilientClient`] provides:
//!
//! - **Connection Pooling**: Reuses connections across requests
//! - **Circuit Breaker**: Stops sending requests to failing servers
//! - **Retries**: Automatic retries with exponential backoff
//! - **Failover**: Tries multiple bootstrap servers
//!
//! ```rust,ignore
//! use rivven_client::{ResilientClient, ResilientClientConfig};
//!
//! # async fn example() -> rivven_client::Result<()> {
//! let config = ResilientClientConfig::builder()
//! .servers(vec![
//! "broker1:9092".to_string(),
//! "broker2:9092".to_string(),
//! "broker3:9092".to_string(),
//! ])
//! .max_connections(20)
//! .max_retries(5)
//! .circuit_breaker_threshold(3)
//! .circuit_breaker_timeout(std::time::Duration::from_secs(30))
//! .build()?;
//!
//! let client = ResilientClient::new(config).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Request Pipelining
//!
//! For maximum throughput, use [`PipelinedClient`] which allows multiple
//! in-flight requests over a single connection:
//!
//! ```rust,ignore
//! use rivven_client::{PipelinedClient, PipelineConfig};
//!
//! # async fn example() -> rivven_client::Result<()> {
//! // High-throughput configuration
//! let config = PipelineConfig::high_throughput();
//! let client = PipelinedClient::connect("127.0.0.1:9092", config).await?;
//!
//! // Send 1000 requests concurrently
//! let handles: Vec<_> = (0..1000)
//! .map(|i| {
//! let client = client.clone();
//! tokio::spawn(async move {
//! client.publish("topic", format!("msg-{}", i)).await
//! })
//! })
//! .collect();
//!
//! for handle in handles {
//! handle.await??;
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ## Feature Flags
//!
//! - `tls` - Enable TLS support via rustls
//!
//! ## High-Performance Producer
//!
//! For maximum throughput with all best practices, use [`Producer`]:
//!
//! ```rust,ignore
//! use rivven_client::{Producer, ProducerConfig};
//! use std::sync::Arc;
//!
//! let config = ProducerConfig::builder()
//! .bootstrap_servers(vec!["localhost:9092".to_string()])
//! .batch_size(16384)
//! .linger_ms(5)
//! .enable_idempotence(true)
//! .build()?;
//!
//! let producer = Arc::new(Producer::new(config).await?);
//!
//! // Thread-safe sharing
//! for i in 0..1000 {
//! let producer = Arc::clone(&producer);
//! tokio::spawn(async move {
//! producer.send("topic", format!("msg-{}", i)).await
//! });
//! }
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// Re-export TLS configuration when available
pub use TlsConfig;
// Re-export protocol types from rivven-protocol
pub use ;