Skip to content

Instantly share code, notes, and snippets.

View ChillFish8's full-sized avatar
We got the zoomies!

Harrison Burt ChillFish8

We got the zoomies!
View GitHub Profile
import sqlite3
from sqlite3 import Error
from datetime import datetime
print(sqlite3.version)
# Prefix Load up
class PrefixDB:
def __init__(self):
#[pyclass]
struct TestIssue {
rt: tokio::runtime::Runtime,
}
#[pymethods]
impl TestIssue {
#[new]
fn new() -> Self {
[
"john grishamme",
"helloo world, todayy we will party on saturdy",
"best booke i've listened to!",
"pushing searches to it's limitss!",
"here's some searchh samples in all it's glorary",
"favouritee "
]
@ChillFish8
ChillFish8 / datacake-crdt.rs
Created January 6, 2023 14:38
The CRDT implementation with a timestamp.
use std::time::Duration;
use datacake_crdt::{OrSWotSet, HLCTimestamp};
fn main() {
let mut node_a = HLCTimestamp::now(0, 0);
// Simulating a node begin slightly ahead in time.
let mut node_b = HLCTimestamp::new(node_a.datacake_timestamp() + Duration::from_secs(5), 0, 1);
let mut node_a_set = OrSWotSet::default();
use datacake_node::{ClusterExtension, DatacakeNode};
use async_trait::async_trait;
pub struct MyExtension;
#[async_trait]
impl ClusterExtension for MyExtension {
type Output = ();
type Error = MyError;
use std::net::SocketAddr;
use datacake_node::{ConnectionConfig, DCAwareSelector, DatacakeNodeBuilder};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let bind_addr = "127.0.0.1:8000".parse::<SocketAddr>().unwrap();
// We setup our connection config for the node passing in the bind address, public address and seed nodes.
// Here we're just using the bind address as our public address with no seed, but in the real world
use datacake_node::{ClusterExtension, DatacakeNode};
use async_trait::async_trait;
pub struct MyExtension;
#[async_trait]
impl ClusterExtension for MyExtension {
type Output = ();
type Error = MyError;
use std::net::SocketAddr;
use bytecheck::CheckBytes;
use datacake_rpc::{
Channel,
Handler,
Request,
RpcClient,
RpcService,
Server,
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()
use anyhow::Result;
use std::net::SocketAddr;
use datacake_eventual_consistency::EventuallyConsistentStoreExtension;
use datacake_node::{
ConnectionConfig,
Consistency,
DCAwareSelector,
DatacakeNodeBuilder,
};
use datacake_sqlite::SqliteStorage;