Hacker News

Peer-to-peer event-sourced DB

by @noworriesnate

I'm building an in-process, peer-to-peer, event sourced, categorical database in Rust. I think more and more people are going to start building their own personal apps, and people are not going to want to have to manage a server. So the tradeoff this database makes is it doesn't work at high scale, but it has a lot of features not typically in a database, such as: - The ability to embed non-turing-complete event source handlers in the database schema - Categorical type system that makes migrations provably secure - All schema changes take place through migrations Example syntax: Inventory = aggregate(key = sku) { sku: String name: String available: crdt(merge = counter) I64 command Stock(sku: String, name: String, qty: U64) { sku = input.sku name = input.name available += input.qty } command Reserve(sku: String, qty: U64) { available -= input.qty } command Release(sku: String, qty: U64) { available += input.qty } } command SubmitOrder(order_id: String, party_id: String, sku: String, qty: U64, total: U64) { Order::PlaceOrder( id = input.order_id party_id = input.party_id sku = input.sku qty = input.qty total = input.total ) compensate Order::Cancel() # `sku` is Inventory's key — the step must bind it so the engine can # resolve which Inventory row the command targets (task-212). Inventory::Reserve(sku = input.sku, qty = input.qty) compensate Inventory::Release(sku = input.sku, qty = input.qty) }

Discover more builders

Builderlust is an endless, joyful scroll of real projects people are shipping right now. Get the app to keep finding your next spark of inspiration.

📱 Coming soon to iOS & AndroidOpen in the app