Crate datacake_eventual_consistency

Crate datacake_eventual_consistency 

Source
Expand description

§Datacake Cluster

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.

RPC is provided and managed entirely within Datacake using Tonic and GRPC.

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 2 async traits.

§Basic Example

use std::net::SocketAddr;
use datacake_node::{Consistency, ConnectionConfig, DCAwareSelector, DatacakeNodeBuilder};
use datacake_eventual_consistency::test_utils::MemStore;
use datacake_eventual_consistency::EventuallyConsistentStoreExtension;

#[tokio::main]
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(())
}

§Complete Examples

Indepth examples can be found here.

Structs§

BulkMutationError
An error which occurred while mutating the state not allowing the operation to proceed any further but also having some part of the operation complete.
Document
A single document managed by the store.
DocumentMetadata
The metadata attached to each document.
EventuallyConsistentStore
A fully managed eventually consistent state controller.
EventuallyConsistentStoreExtension
A fully managed eventually consistent state controller.
ProgressTracker
A simple atomic counter to indicate to supervisors that the given operation is making progress.
PutContext
Additional information related to the operation which can be useful.
ReplicatedStoreHandle
A cheaply cloneable handle to control the data store.
ReplicatorKeyspaceHandle
A convenience wrapper which creates a new handle with a preset keyspace.
SystemStatistics
Live metrics around the cluster system.

Enums§

StoreError
A wrapping error for the store which can potentially fail under situations.

Traits§

Storage
The generic storage trait which encapsulates all the required persistence logic.