Expand description
§KVStore SMR Example
A key-value store implementation that demonstrates how to create a State Machine Replication (SMR) application using the Rabia consensus protocol.
§Features
- SMR Implementation: Clean implementation of the StateMachine trait
- Key-Value Operations: Support for SET, GET, DELETE, and EXISTS operations
- Change Notifications: Event-driven updates via message bus
- State Serialization: Full state serialization for consensus integration
- Production Ready: Comprehensive error handling and monitoring
§Example Usage
use rabia_kvstore_example::{KVStoreSMR, KVOperation, KVStoreConfig};
use rabia_core::smr::StateMachine;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut kvstore = KVStoreSMR::new_default().await?;
let command = KVOperation::Set {
key: "hello".to_string(),
value: "world".to_string(),
};
let response = kvstore.apply_command(command).await;
println!("Response: {:?}", response);
Ok(())
}Re-exports§
pub use notifications::ChangeNotification;pub use notifications::NotificationBus;pub use notifications::SubscriptionId;pub use operations::KVOperation;pub use operations::KVResult;pub use operations::StoreError;pub use smr_impl::KVStoreSMR;pub use smr_impl::KVStoreState;pub use store::KVStore;pub use store::KVStoreConfig;pub use store::StoreSnapshot;
Modules§
- notifications
- Change Notification System
- operations
- KVStore Operations and Error Types
- smr_
impl - KVStore SMR Implementation
- store
- KVStore Implementation
Traits§
- State
Machine - Re-export commonly used types for convenience Core trait for State Machine Replication in Rabia consensus.