pub struct Client { /* private fields */ }Expand description
Rivven client for connecting to a Rivven server
Implementations§
Source§impl Client
impl Client
Sourcepub async fn authenticate(
&mut self,
username: &str,
password: &str,
) -> Result<AuthSession>
pub async fn authenticate( &mut self, username: &str, password: &str, ) -> Result<AuthSession>
Authenticate with simple username/password
This uses a simple plaintext password protocol. For production use over
untrusted networks, prefer authenticate_scram() or use TLS.
Sourcepub async fn authenticate_scram(
&mut self,
username: &str,
password: &str,
) -> Result<AuthSession>
pub async fn authenticate_scram( &mut self, username: &str, password: &str, ) -> Result<AuthSession>
Authenticate using SCRAM-SHA-256 (secure challenge-response)
SCRAM-SHA-256 (RFC 5802/7677) provides:
- Password never sent over the wire
- Mutual authentication (server proves it knows password too)
- Protection against replay attacks
§Example
let mut client = Client::connect("127.0.0.1:9092").await?;
let session = client.authenticate_scram("alice", "password123").await?;
println!("Session: {} (expires in {}s)", session.session_id, session.expires_in);Sourcepub async fn publish(
&mut self,
topic: impl Into<String>,
value: impl Into<Bytes>,
) -> Result<u64>
pub async fn publish( &mut self, topic: impl Into<String>, value: impl Into<Bytes>, ) -> Result<u64>
Publish a message to a topic
Sourcepub async fn publish_with_key(
&mut self,
topic: impl Into<String>,
key: Option<impl Into<Bytes>>,
value: impl Into<Bytes>,
) -> Result<u64>
pub async fn publish_with_key( &mut self, topic: impl Into<String>, key: Option<impl Into<Bytes>>, value: impl Into<Bytes>, ) -> Result<u64>
Publish a message with a key to a topic
Sourcepub async fn publish_to_partition(
&mut self,
topic: impl Into<String>,
partition: u32,
key: Option<impl Into<Bytes>>,
value: impl Into<Bytes>,
) -> Result<u64>
pub async fn publish_to_partition( &mut self, topic: impl Into<String>, partition: u32, key: Option<impl Into<Bytes>>, value: impl Into<Bytes>, ) -> Result<u64>
Publish a message to a specific partition
Sourcepub async fn consume(
&mut self,
topic: impl Into<String>,
partition: u32,
offset: u64,
max_messages: usize,
) -> Result<Vec<MessageData>>
pub async fn consume( &mut self, topic: impl Into<String>, partition: u32, offset: u64, max_messages: usize, ) -> Result<Vec<MessageData>>
Consume messages from a topic partition
Sourcepub async fn create_topic(
&mut self,
name: impl Into<String>,
partitions: Option<u32>,
) -> Result<u32>
pub async fn create_topic( &mut self, name: impl Into<String>, partitions: Option<u32>, ) -> Result<u32>
Create a new topic
Sourcepub async fn list_topics(&mut self) -> Result<Vec<String>>
pub async fn list_topics(&mut self) -> Result<Vec<String>>
List all topics
Sourcepub async fn commit_offset(
&mut self,
consumer_group: impl Into<String>,
topic: impl Into<String>,
partition: u32,
offset: u64,
) -> Result<()>
pub async fn commit_offset( &mut self, consumer_group: impl Into<String>, topic: impl Into<String>, partition: u32, offset: u64, ) -> Result<()>
Commit consumer offset
Sourcepub async fn get_offset(
&mut self,
consumer_group: impl Into<String>,
topic: impl Into<String>,
partition: u32,
) -> Result<Option<u64>>
pub async fn get_offset( &mut self, consumer_group: impl Into<String>, topic: impl Into<String>, partition: u32, ) -> Result<Option<u64>>
Get consumer offset
Sourcepub async fn get_offset_bounds(
&mut self,
topic: impl Into<String>,
partition: u32,
) -> Result<(u64, u64)>
pub async fn get_offset_bounds( &mut self, topic: impl Into<String>, partition: u32, ) -> Result<(u64, u64)>
Get earliest and latest offsets for a topic partition
Returns (earliest, latest) where:
- earliest: First available offset (messages before this are deleted/compacted)
- latest: Next offset to be assigned (one past the last message)
Sourcepub async fn get_metadata(
&mut self,
topic: impl Into<String>,
) -> Result<(String, u32)>
pub async fn get_metadata( &mut self, topic: impl Into<String>, ) -> Result<(String, u32)>
Get topic metadata
Sourcepub async fn register_schema(
&mut self,
subject: impl Into<String>,
schema: impl Into<String>,
) -> Result<i32>
pub async fn register_schema( &mut self, subject: impl Into<String>, schema: impl Into<String>, ) -> Result<i32>
Register a schema
Sourcepub async fn get_schema(&mut self, id: i32) -> Result<String>
pub async fn get_schema(&mut self, id: i32) -> Result<String>
Get a schema
Sourcepub async fn list_groups(&mut self) -> Result<Vec<String>>
pub async fn list_groups(&mut self) -> Result<Vec<String>>
List all consumer groups
Sourcepub async fn describe_group(
&mut self,
consumer_group: impl Into<String>,
) -> Result<HashMap<String, HashMap<u32, u64>>>
pub async fn describe_group( &mut self, consumer_group: impl Into<String>, ) -> Result<HashMap<String, HashMap<u32, u64>>>
Describe a consumer group (get all committed offsets)
Sourcepub async fn delete_group(
&mut self,
consumer_group: impl Into<String>,
) -> Result<()>
pub async fn delete_group( &mut self, consumer_group: impl Into<String>, ) -> Result<()>
Delete a consumer group
Sourcepub async fn get_offset_for_timestamp(
&mut self,
topic: impl Into<String>,
partition: u32,
timestamp_ms: i64,
) -> Result<Option<u64>>
pub async fn get_offset_for_timestamp( &mut self, topic: impl Into<String>, partition: u32, timestamp_ms: i64, ) -> Result<Option<u64>>
Get the first offset with timestamp >= the given timestamp
§Arguments
topic- The topic namepartition- The partition numbertimestamp_ms- Timestamp in milliseconds since Unix epoch
§Returns
Some(offset)- The first offset with message timestamp >= timestamp_msNone- No messages found with timestamp >= timestamp_ms