Skip to main content

Crate rivven_client

Crate rivven_client 

Source
Expand description

§rivven-client

Native async Rust client library for 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

use rivven_client::{ResilientClient, ResilientClientConfig};

// 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?;

§Authentication

The client supports SCRAM-SHA-256 authentication:

use rivven_client::{Client, AuthSession};

let mut client = Client::connect("127.0.0.1:9092").await?;

// Authenticate with SCRAM-SHA-256
client.authenticate_scram("username", "password").await?;

§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
use rivven_client::{ResilientClient, ResilientClientConfig};

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?;

§Feature Flags

  • tls - Enable TLS support via rustls

Re-exports§

pub use client::AuthSession;
pub use client::Client;
pub use error::Error;
pub use error::Result;
pub use resilient::ResilientClient;
pub use resilient::ResilientClientConfig;
pub use resilient::ResilientClientConfigBuilder;

Modules§

client
error
resilient
Production-grade resilient client with connection pooling, retries, and circuit breaker

Structs§

BrokerInfo
Broker/node information for metadata discovery
MessageData
Serialized message data for transport
PartitionMetadata
Partition metadata for cluster discovery
TopicMetadata
Topic metadata for cluster discovery

Enums§

Request
Protocol request messages
Response
Protocol response messages

Constants§

MAX_MESSAGE_SIZE
Maximum message size (64 MiB)
PROTOCOL_VERSION
Protocol version for compatibility checking