Evento
Event sourcing and CQRS toolkit with SQL persistence, projections, and subscriptions.
More information about this crate can be found in the crate documentation.
Features
- Event Sourcing: Store state changes as immutable events with complete audit trail
- CQRS Pattern: Separate read and write models for scalable architectures
- SQL Database Support: Built-in support for SQLite, PostgreSQL, and MySQL
- Embedded Storage: Fjall key-value store for embedded applications
- Event Handlers: Async event processing with automatic retries
- Event Subscriptions: Continuous event stream processing with cursor tracking
- Projections: Build read models by replaying events
- Database Migrations: Automated schema management
- Compact Serialization: Fast binary serialization with bitcode
- Type Safety: Fully typed events and aggregates with compile-time guarantees
Installation
Add to your Cargo.toml:
[]
= { = "2", = ["sqlite"] }
= "0.6"
Usage Example
use ;
// Define events using an enum
// Define a view/projection
// Define handler functions
async
async
async
Continuous Subscriptions
use Duration;
// Start a subscription that continuously processes events
let subscription = new
.handler
.handler
.subscription
.routing_key
.chunk_size
.retry
.delay
.start
.await?;
// On application shutdown
subscription.shutdown.await?;
Feature Flags
macro(enabled by default) - Procedural macros for cleaner codegroup- Multi-executor support for querying across databasesrw- Read-write split executor for CQRS patternssql- Enable all SQL database backends (SQLite, MySQL, PostgreSQL)sqlite- SQLite support via sqlxmysql- MySQL support via sqlxpostgres- PostgreSQL support via sqlxfjall- Embedded key-value storage with Fjall
Minimum Supported Rust Version
Evento's MSRV is 1.75.
Safety
This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in 100% safe Rust.
Examples
The examples directory contains sample applications demonstrating various features:
- bank - Bank account domain model with commands, queries, and projections
- bank-axum-sqlite - Integration with Axum web framework and SQLite
Getting Help
If you have questions or need help, please:
- Check the documentation
- Look at the examples
- Open an issue on GitHub
License
This project is licensed under the Apache-2.0 license.