Evento
A collection of libraries and tools that help you build DDD, CQRS, and event sourcing applications in Rust.
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
- Event Handlers: Async event processing with automatic retries
- Event Subscriptions: Continuous event stream processing
- Event Streaming: Real-time event streams (with
streamfeature) - Snapshots: Periodic state captures to optimize aggregate loading
- Database Migrations: Automated schema management
- Macro Free API: Clean, macro-free API (macros available optionally)
- Type Safety: Fully typed events and aggregates with compile-time guarantees
Usage Example
use ;
use ;
use ;
// Define events
// Define aggregate
// Implement event handlers on the aggregate
async
Event Handlers and Subscriptions
use ;
// Define a handler function
async
// Subscribe to events
subscribe
.handler
.run
.await?;
Feature Flags
macro(enabled by default) Enable procedural macros for cleaner codehandler(enabled by default) Enable event handlers with retry supportstreamEnable streaming support withtokio-streamgroupEnable event grouping functionalitysqlEnable all SQL database backends (SQLite, MySQL, PostgreSQL)sqliteSQLite support via sqlxmysqlMySQL support via sqlxpostgresPostgreSQL support via sqlx
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:
- todos - A complete todo application with CQRS, demonstrating command/query separation and event handlers
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.