Crates.io | datacake-eventual-consistency |
lib.rs | datacake-eventual-consistency |
version | 0.5.1 |
source | src |
created_at | 2023-01-06 00:01:11.466779 |
updated_at | 2023-06-22 18:44:32.627282 |
description | Eventually consistent state replication as a library (consensus, RPC and conflict resolution) for building your own eventually consistent databases. |
homepage | |
repository | https://github.com/lnx-search/datacake |
max_upload_size | |
id | 751892 |
size | 206,706 |
A batteries included library for building your own distributed data stores or replicated state.
This library is largely based on the same concepts as Riak and Cassandra. Consensus, membership and failure detection are managed by Quickwit's Chitchat while state alignment and replication is managed by Datacake CRDT.
This library is focused around providing a simple and easy to build framework for your distributed apps without being overwhelming. In fact, you can be up and running just by implementing 1 async trait.
use std::net::SocketAddr;
use datacake_node::{Consistency, ConnectionConfig, DCAwareSelector, DatacakeNodeBuilder};
use datacake_eventual_consistency::test_utils::MemStore;
use datacake_eventual_consistency::EventuallyConsistentStoreExtension;
async fn main() -> anyhow::Result<()> {
let addr = "127.0.0.1:8080".parse::<SocketAddr>().unwrap();
let connection_cfg = ConnectionConfig::new(addr, addr, Vec::<String>::new());
let node = DatacakeNodeBuilder::<DCAwareSelector>::new(1, connection_cfg)
.connect()
.await
.expect("Connect node.");
let store = node
.add_extension(EventuallyConsistentStoreExtension::new(MemStore::default()))
.await
.expect("Create store.");
let handle = store.handle();
handle
.put(
"my-keyspace",
1,
b"Hello, world! From keyspace 1.".to_vec(),
Consistency::All,
)
.await
.expect("Put doc.");
Ok(())
}
Indepth examples can be found here.