Crate d_engine_client

Crate d_engine_client 

Source
Expand description

§d-engine-client

Client library for interacting with d-engine Raft clusters via gRPC

§⚠️ You Probably Don’t Need This Crate

Use d-engine instead:

[dependencies]
d-engine = { version = "0.2", features = ["client"] }

This provides the same API with simpler dependency management. The d-engine-client crate is automatically included when you enable the client feature.

§For Contributors

This crate exists for architectural reasons:

  • Clean boundaries between client and server
  • Faster builds during development
  • Isolated client testing

§Quick Start

use d_engine_client::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::connect(vec!["http://localhost:50051"]).await?;

    // Write data
    client.put(b"key".to_vec(), b"value".to_vec()).await?;

    // Read data
    if let Some(value) = client.get(b"key".to_vec()).await? {
        println!("Value: {:?}", value);
    }

    Ok(())
}

§Read Consistency

Choose consistency level based on your needs:

  • get_linearizable() - Strong consistency (read from Leader)
  • get_eventual() - Fast local reads (stale OK)
  • get_lease() - Optimized with leader lease

§Features

This crate provides:

§Documentation

For comprehensive guides:

Re-exports§

pub use kv_client::*;
pub use kv_error::*;

Modules§

cluster_types
Cluster management protocol types
kv_client
KV client trait - unified interface for key-value operations.
kv_error
Error types for KV client operations.
protocol
Protocol types needed for client operations

Structs§

Client
Main entry point for interacting with the d_engine cluster
ClientBuilder
Configurable builder for Client instances
ClientConfig
Client configuration parameters for network connection management
ClientInner
ClusterClient
Cluster administration interface
ConnectionPool
Manages connections to cluster nodes
GrpcKvClient
gRPC-based key-value store client
LeaderHint
Leader hint for client redirection Used at: Network layer (gRPC error responses) Purpose: Help clients redirect requests to the current leader Fields: Includes network address for immediate retry

Enums§

ClientApiError

Functions§

get_duration_since_epoch
get_now_as_u32
Returns seconds since epoch as u32