Created
January 6, 2023 15:06
-
-
Save ChillFish8/6544cee463b7479f7a1ae6ed1f2bc86d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment