Experiments with Rust CRDTs using Tokio web application framework Axum.

Overview

crdt-genome

Synopsis

Experiments with Rust CRDTs using Tokio web application framework Axum.

Background

Exploring some ideas of Martin Kleppmann, particularly Local-First software.

See this Podcast

Also this conference talk

Scenario

A group of Axum executeables represents a group of Actors.

Each actor process maintains a genome, represented by a CRDT List.

pub struct Genome {
    genes: ListOfGenes,
}

Each process mutates its genome at random intervals and circulates a CmRDT Op using HTTP POST.

The goal is to observe every genome instance converging to a common value.

Caveat

This little system has serious shortcomings. If a process joins late, or drops out and rejoins, or even loses a single POST request, it will never have the full genome.

Execution

see scripts/run-test.sh

to run some actors, first bring the executeable up to date:

cargo build

Then run instances of the executeable

#!/bin/bash
set -euxo pipefail

target/debug/crdt-genome --actor=0 --count=3 --base=8000 2>&1 | tee actor-0.log &
target/debug/crdt-genome --actor=1 --count=3 --base=8000 2>&1 > actor-1.log &
target/debug/crdt-genome --actor=2 --count=3 --base=8000 2>&1 > actor-2.log &
USAGE:
    crdt-genome --actor <actor> --base <base> --count <count>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -a, --actor <actor>    the actor id of this server
    -b, --base <base>      base port number
    -c, --count <count>    The number of actors

Verification

We want to verify that every genome is converging to the same value.

Since the system is constantly changing, there is no absolute way to do this.

We use HTTP GET to return a string representation of the genome.

$ curl localhost:8000/genome
40fd70816b4f664be2f28766

At a fixed interval, each process polls all the others and compares its genome representation with theirs. For this test, we simply log the result.

$ grep "match" actor-1.log 
Oct 24 15:24:05.500 DEBUG crdt_genome: match count = 6
Oct 24 15:24:10.516 DEBUG crdt_genome: match count = 9
Oct 24 15:24:15.528 DEBUG crdt_genome: match count = 9
Oct 24 15:24:20.540 DEBUG crdt_genome: match count = 9
Oct 24 15:24:25.551 DEBUG crdt_genome: match count = 9
Oct 24 15:24:30.561 DEBUG crdt_genome: match count = 9
Oct 24 15:24:35.573 DEBUG crdt_genome: match count = 9
Oct 24 15:24:40.587 DEBUG crdt_genome: match count = 9
Oct 24 15:24:45.601 DEBUG crdt_genome: match count = 9
Oct 24 15:24:50.613 DEBUG crdt_genome: match count = 9
Oct 24 15:24:55.623 DEBUG crdt_genome: match count = 9
Oct 24 15:25:00.635 DEBUG crdt_genome: match count = 9
Oct 24 15:25:05.646 DEBUG crdt_genome: match count = 9
Oct 24 15:25:10.657 DEBUG crdt_genome: match count = 9
You might also like...
Sauron is an html web framework for building web-apps. It is heavily inspired by elm.
Sauron is an html web framework for building web-apps. It is heavily inspired by elm.

sauron Guide Sauron is an web framework for creating fast and interactive client side web application, as well as server-side rendering for back-end w

A (flash) message framework for actix-web. A port to Rust of Django's message framework.

actix-web-flash-messages Flash messages for actix-web Web applications sometimes need to show a one-time notification to the user - e.g. an error mess

Rust Axum+SQLx Sample

rust-axum-sqlx-sample Install git clone https://github.com/web3ten0/rust-axum-sqlx-1.git cd rust-axum-sqlx-1/local docker-compose up -d sh scripts/exe

Rust Axum Full Course code.

Rust Axum Full Course source code. YouTube Full Course: https://youtube.com/watch?v=XZtlD_m59sM&list=PL7r-PXl6ZPcCIOFaL7nVHXZvBmHNhrh_Q MIT OR Apache,

Rust server with Axum, GraphQL and SurrealDb
Rust server with Axum, GraphQL and SurrealDb

📜️ Article on my web Axum server, Async-GraphQl, SurrealDB template Run without any prior setup, DB is in memory: cargo run To use routes other than

Yew + Axum + blog = Yab

Yew + Axum + blog = Yab

🪪 Session-based user authentication for Axum.

axum-login 🪪 Session-based user authentication for Axum. 🎨 Overview axum-login is a Tower middleware providing session-based user authentication for

🔎 Prometheus metrics middleware for Axum

Axum-Prometheus A Prometheus middleware to collect HTTP metrics for Axum applications. axum-prometheus relies on metrics_exporter_prometheus as a back

Provides json/csv/protobuf streaming support for axum

axum streams for Rust Library provides HTTP response streaming support for axum web framework: JSON array stream format JSON lines stream format CSV s

Releases(v0.1.0)
  • v0.1.0(Oct 24, 2021)

    Runnable system. Basic verification

    What's Changed

    • Start-crdt-genome by @dougfort in https://github.com/dougfort/crdt-genome/pull/1
    • replace println with tracing by @dougfort in https://github.com/dougfort/crdt-genome/pull/2
    • add verifier by @dougfort in https://github.com/dougfort/crdt-genome/pull/4

    New Contributors

    • @dougfort made their first contribution in https://github.com/dougfort/crdt-genome/pull/1

    Full Changelog: https://github.com/dougfort/crdt-genome/commits/v0.1.0

    Source code(tar.gz)
    Source code(zip)
Owner
dougfort
programmer
dougfort
Demo of Rust and axum web framework

Demo of Rust and axum web framework Demonstration of: Rust: programming language that focuses on reliability and stability. axum: web framework that f

Joel Parker Henderson 115 Dec 29, 2022
Axum web framework tutorial for beginners.

Axum Tutorial For Beginners Hello web developers! This tutorial will cover how to write simple web applications in rust with axum framework. If you ar

Eray Karatay 46 Jan 5, 2023
Starter template for use with the Leptos web framework and Axum.

Leptos Axum Starter Template This is a template for use with the Leptos web framework and the cargo-leptos tool using Axum. Creating your template rep

Leptos 10 Mar 4, 2023
Ergonomic and modular web framework built with Tokio, Tower, and Hyper

axum axum is a web application framework that focuses on ergonomics and modularity. More information about this crate can be found in the crate docume

Tokio 7.9k Dec 31, 2022
JWT Authentication in Rust using Axum Framework

Are you interested in building a secure authentication system for your Rust web application? Look no further than the Axum framework and JSON Web Tokens (JWTs)! Axum is a fast and scalable Rust web framework that provides a reliable and efficient platform for developing microservices and APIs.

CODEVO 16 Jun 11, 2023
Layers, extractors and template engine wrappers for axum based Web MVC applications

axum-template Layers, extractors and template engine wrappers for axum based Web MVC applications Getting started Cargo.toml [dependencies] axum-templ

Altair Bueno 11 Dec 15, 2022
Axum + Connect-Web = ♥️

Axum Connect-Web ⚠️ This project isn't even Alpha state yet. Don't use it. Brings the protobuf-based Connect-Web RPC framework to Rust via idiomatic A

Alec Thilenius 10 Mar 19, 2023
This is a simple Api template for Rust ( Axum framework )

Axum-Rust-Rest-Api-Template This project is an open source Rest Api Template built with Rust's Axum framework. Why this project? I have been learning

Thani 20 Jun 16, 2023
Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

Actix 16.2k Jan 2, 2023
Web Application with using Rust(Actix, Diesel and etc)

Santa Service App Used technology stack Web Server with using Rust (Actix, Actix-web, Diesel) Data base (Postgres) Console Application (Tokio) Tasks o

null 3 Jan 8, 2023