Git Product home page Git Product logo

thalo's Introduction

Thalo โ€” Event sourcing runtime for wasm

Crates.io Documentation MIT OR Apache-2.0 Stargazers Last commit Discord

Overview

Thalo is an event sourcing runtime for building distributed systems. It is built on top of Wasmtime for components, and uses Message DB for the message store.

Thalo is still in alpha, consider carefully before using for any production apps.

Aggregates are compiled to wasm from any supported programming language, and published to the registry, where it is used by the runtime to handle commands.

Getting Started

Crates are not published yet as they depend on some git dependencies. Once wit-bindgen crates are published, then Thalo may be also published to crates.io

The Thalo crates currently published to crates.io are outdated and are an old incompatible version.

To use Thalo now, you'll need to import it with the git url.

[dependencies]
thalo = { git = "https://github.com/thalo-rs/thalo" }

Current crates in this repository include:

  • thalo - Core library.
  • thalo_cli - CLI utility for publishing modules and executing commands.
  • thalo_runtime - Runtime used to handle commands and persist events.
  • thalo_registry - Module registry, for storing and retrieving modules.

The best way to get started for now is by looking at the examples, or reaching out on our Discord server.

What is Event Sourcing

Event sourcing is programming pattern based on immutable events which act as the source of truth for your application.

Rather than the traditional state-oriented approach, your data consists of small events, and your models can be built by replaying these events one by one to compute read models.

A common example of event sourcing is accounting, where your bank balance is the sum of all your transactions (aka events). A more familiar technology using event sourcing is Git.

What are the benefits?

  • Scalability

    Event sourced systems can operate in a very loosely coupled parallel style which provides excellent horizontal scalability and resilience to systems failure.

  • Time Travel

    By storing immutable events, you have the ability to determine application state at any point in time.

  • Expressive Models

    Events are first class objects in your system and show intent behind data changes. It makes the implicit explicit.

What are the down sides?

As with anything in the tech world, everything is about trade-offs.

There are some reasons not to use event sourcing in your system including:

  • Eventual consistency: With the separation of concerns comes eventual consistency in your system, meaning your data may not be up to date immediately, but eventually will become consistent.

  • Hard to get Right: It can be difficult to navigate this pattern when coming from the CRUD world, and there can be a lot of conflicting information online.

  • Idempotency: Command and event handlers need to be written with idempotency in mind, meaning the same event handled should not be reprocessed.

  • High Disk Usage: With all events being stored forever, disk usage will grow overtime. Though there are solutions to this such as snapshotting.

Resources

Here are some useful resources on event sourcing & CQRS:

Why

The Event Sourcing & CQRS ecosystem seems to be dominated by C# and Java. Thalo aims to expand this reach using WebAssembly, allowing components to be written in any supported language, not just Rust.

ESDL - Event-sourcing Schema Definition Language

Aggregates, commands and events are defined in the ESDL schema language.

This allows for more readable aggregate definitions and provides code generation to generate types and traits.

An example of an .esdl can be found in examples/bank_account/bank_account.esdl.

Supported Languages

For now, only Rust is supported, but in the future I hope to add support for other languages including AssemblyScript, Grain lang, Python.

Examples

Examples include:

All examples can be seen in the examples directory.

Getting Help

As Thalo is in pre-release, the API is not stable yet. If you'd like to get started using Thalo, you can checkout the examples directory, or chat on the Discord server.

Contributing

๐ŸŽˆ Thanks for your help improving the project! As we don't currently have a contributing guide, you can ping us on the Discord server or open an issue.

License

This project is licensed under the MIT OR Apache-2.0 license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Thalo by you, shall be licensed as MIT, without any additional terms or conditions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.