Skip to main content

Crate d_engine

Crate d_engine 

Source
Expand description

§d-engine - Distributed Coordination Engine

d-engine is a lightweight distributed coordination engine written in Rust, designed for embedding into applications that need strong consistency—the consensus layer for building reliable distributed systems.

Built with a simple vision: make distributed coordination accessible - cheap to run, simple to use. Built on a core philosophy: choose simple architectures over complex ones.

d-engine’s Raft core uses a single-threaded event loop to guarantee strong consistency and strict ordering while keeping the codebase clean and performant. Production-ready Raft implementation with flexible read consistency (Linearizable/Lease-Based/Eventual) and pluggable storage backends. Start with one node, scale to a cluster when needed.

§🚀 New to d-engine? Start Here

Follow this learning path to get started quickly:

1. Is d-engine Right for You? (1 minute)
   ↓
2. Choose Integration Mode (1 minute)
   ↓
3a. Quick Start - Embedded (5 minutes)
   OR
3b. Quick Start - Standalone (5 minutes)
   ↓
4. Scale to Cluster (optional)

→ Start: Is d-engine Right for You?

§Recommended Entry Point

This is the recommended crate for most users. It re-exports all functionality from the internal crates below.

[dependencies]
d-engine = "0.2"  # This is all you need

§Crate Organization

CratePurpose
d-engine-protoProtocol definitions (Prost)
d-engine-coreCore Raft algorithm & traits
d-engine-clientClient library for applications
d-engine-serverServer runtime implementation

§Quick Start

§Embedded Mode (Rust)

ⓘ
use d_engine::prelude::*;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let engine = EmbeddedEngine::start_with("d-engine.toml").await?;
    engine.wait_ready(std::time::Duration::from_secs(5)).await?;

    let client = engine.client();
    client.put(b"key".to_vec(), b"value".to_vec()).await?;

    Ok(())
}

→ 5-Minute Embedded Guide

§Standalone Mode (Any Language)

cd examples/three-nodes-standalone
make start-cluster

→ Standalone Guide

§Documentation Index

§Getting Started

§Guides by Role

§Client Developers
§Server Operators

§Examples & Performance

§License

MIT or Apache-2.0

Modules§

api
Public API layer for different deployment modes
client
Client protocol types
cluster_types
Cluster management protocol types
common
Common Raft protocol types
docs
Documentation modules
node
Node lifecycle management
prelude
Convenient prelude for importing common types
protocol
Protocol types needed for client operations
server_storage
Server storage protocol types
storage
Storage layer implementations

Structs§

ApplyResult
Result of applying a single log entry to the state machine
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
ConnectionPool
Manages connections to cluster nodes
EmbeddedClient
Zero-overhead KV client for embedded mode.
EmbeddedEngine
Embedded d-engine with automatic lifecycle management.
FileStateMachine
File-based state machine implementation with persistence
FileStorageEngine
File-based Raft log storage
GrpcClient
gRPC-based key-value store client
HardState
LeaderInfo
Leader election information Used at: Application layer (internal Raft protocol notifications) Purpose: Notify applications about leader changes via watch channel Fields: Minimal - only what Raft protocol needs
Node
Raft consensus node
NodeBuilder
Builder for creating a Raft node
Raft
RocksDBStateMachine
RocksDB-based state machine implementation with lease support
RocksDBStorageEngine
RocksDB-based Raft log storage
StandaloneEngine
Standalone d-engine engine for independent deployment

Enums§

ClientApiError
Error
ProstError
Wrapper for prost encoding/decoding errors
SnapshotError
StorageError

Traits§

ClientApi
Unified key-value store interface.
LogStore
MetaStore
Metadata storage operations
StateMachine
State machine trait for Raft consensus
StorageEngine
High-performance storage abstraction for Raft consensus

Functions§

get_duration_since_epoch
get_now_as_u32
Returns seconds since epoch as u32

Type Aliases§

ClientApiResult
Result type for KV operations