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:
Client- Main entry point with cluster accessClientBuilder- Configurable client constructionKvClient- Key-value store operations traitClusterClient- Cluster management operations
§Documentation
For comprehensive guides:
Re-exports§
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
- Client
Builder - Configurable builder for
Clientinstances - Client
Config - Client configuration parameters for network connection management
- Client
Inner - Cluster
Client - Cluster administration interface
- Connection
Pool - Manages connections to cluster nodes
- Grpc
KvClient - gRPC-based key-value store client
- Leader
Hint - 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§
Functions§
- get_
duration_ since_ epoch - get_
now_ as_ u32 - Returns seconds since epoch as u32