Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork17
An Event Sourcing runtime with WebAssembly & embedded event store
License
thalo-rs/thalo
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Important
Thalo is currently unmaintained.
New projects are advised to useSierraDB andkameo_es, which together are the successor to Thalo.
Thalo is an event sourcing runtime that leverages the power of WebAssembly (wasm) throughwasmtime, combined withsled as an embedded event store.It is designed to handle commands using compiled aggregate wasm components and to persist the resulting events, efficiently managing the rebuilding of aggregate states from previous events.
- Wasmtime Integration: High-performance, isolated aggregate computation using WebAssembly.
- Sled Event Store: Fast, reliable embedded database for event storage.
- Actor-Based Aggregates: Efficient, lock-free management supporting over 10,000 commands/sec.
- Projections: Projections to handle interested events with an at-least-once gaurantee.
- LRU Caching: Fast aggregate rebuilding with optimized memory usage.
- Streamlined State Management: Automated reconstruction of aggregate states from events.
- Multi-Language Support: Compile aggregates to wasm, enabling diverse language use (currently Rust supported).
- Event Relaying: Events can be relayed to external services (redis streams, etc) with an at-least-once guarantee.
- Rust: Latest stable version of the Rust programming language.
- Thalo: Required for building aggregates to wasm.
- Install with:
cargo install thalo_cli
- Install with:
- Thalo Runtime: Required for running the Thalo event sourcing environment.
- Install with:
cargo install thalo_runtime
- Install with:
Thalo can be started by runningthalo-runtime.
For a list of supported arguments, usethalo_runtime --help.
An aggregate is a regular rust crates which exposes the type implementingthalo::Aggregate with thethalo::export_aggregate! macro.
thalo::export_aggregate!(Counter);structCounter{ ...}impl thalo::AggregateforCounter{ ...}
It can then be compiled with the thalo cli.
$ thalo build counter -o ./modules
The
thalo buildcommand is essentially a wrapper aroundcargo build,handling wasm specifics including converting the resulting binary to a wasm component.
Thalo will automatically load all modules within this the./modules directory, and use them to handle commands.
You can restart the thalo runtime and you should see a message saying our counter was loaded from themodules/counter.wasm file.
$ ./target/debug/thalo-runtimeINFO: loaded module from file file="modules/counter.wasm"We can now send commands to this module with thethalo execute command for testing.
$ thalo execute counter abc123 Increment'{"amount":10}'Executed with 1 events: Incremented {"amount":10}
Counter Example
use serde::{Deserialize,Serialize};use thalo::{events, export_aggregate,Aggregate,Apply,Command,Event,Handle};export_aggregate!(Counter);pubstructCounter{count:u64,}implAggregateforCounter{typeCommand =CounterCommand;typeEvent =CounterEvent;fninit(_id:String) ->Self{Counter{count:0}}}#[derive(Command,Deserialize)]pubenumCounterCommand{Increment{amount:u64},}implHandle<CounterCommand>forCounter{typeError =Infallible;fnhandle(&self,cmd:CounterCommand) ->Result<Vec<CounterEvent>,Self::Error>{match cmd{CounterCommand::Increment{ amount} =>events![Incremented{ amount}],}}}#[derive(Event,Serialize,Deserialize)]pubenumCounterEvent{Incremented(Incremented),}#[derive(Serialize,Deserialize)]pubstructIncremented{pubamount:u64,}implApply<Incremented>forCounter{fnapply(&mutself,event:Incremented){self.count += event.amount;}}
Event sourcing is a design pattern in which changes to the application state are stored as a sequence of events. Instead of storing just the current state, event sourcing involves persisting the full series of actions taken on the data. This allows for:
- Complete State History: Every change is recorded, enabling full traceability and audit trails.
- Easy Reversion: The ability to revert to any previous state by replaying events.
- Complex Event Reconstruction: States can be rebuilt or projections created by processing the event log.
- Improved Scalability and Performance: Decouples data commands from updates, often leading to better system performance.
Event sourcing is particularly useful in systems where understanding the history of operations is crucial, such as financial systems, order management systems, and other domains where auditability and traceability are important.
As Thalo is in pre-release, the API is not stable yet.If you'd like to get started using Thalo, you can checkout theexamples directory, or chat on theDiscord server.
Examples can found in theexamples directory.
🎈 Thanks for your help improving the project! As we don't currently have a contributing guide, you can ping us on theDiscord server or open an issue.
This project is licensed under theMIT ORApache-2.0 license.
Unless you explicitly state otherwise, any contribution intentionally submittedfor inclusion in Thalo by you, shall be licensed as MIT, without any additionalterms or conditions.
About
An Event Sourcing runtime with WebAssembly & embedded event store
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.