eventide
中文版本: README.zh.md
A pragmatic Rust toolkit for Domain-Driven Design with first-class support for event sourcing and CQRS.
eventide is the umbrella crate that re-exports the three building blocks
of the toolkit so you can depend on a single crate and pull in everything
you need.
| Module | Source crate | Purpose |
|---|---|---|
domain |
eventide-domain |
Aggregates, entities, value objects, events, repositories. |
application |
eventide-application |
Command bus, query bus, handlers, application context. |
macros |
eventide-macros |
#[entity], #[entity_id], #[domain_event], #[value_object]. |
Quick start
Add the crate to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["derive"] }
= { = "1", = ["full"] }
= "0.1"
Define an aggregate:
use *;
;
Feature flags
All flags are enabled by default. Disable them selectively with
default-features = false to trim the dependency tree.
| Flag | Default | What it does |
|---|---|---|
eventing |
yes | Asynchronous event subsystem (bus / engine / dispatcher / reclaimer) on top of tokio. |
macros |
yes | Re-export eventide-macros as eventide::macros. |
application |
yes | Re-export eventide-application as eventide::application. |
infra-sqlx |
no | Opt-in sqlx conversions on serialized events / snapshots for Postgres-backed event stores. |
Example: depend on the domain layer only.
[]
= { = "0.1", = false }
Layered architecture
eventide is intentionally split into independent crates so the pieces
you do not need can be left out. The dependency graph flows in one
direction:
eventide-application → eventide-domain ← eventide-macros
↑
└──── (optional) infra-sqlx
The domain crate never depends on application or infrastructure types, which keeps your business logic pure and easy to test.
Why eventide
- Hexagonal-friendly. The domain layer defines the abstractions (
EventRepository,SnapshotRepository,AggregateRepository); infrastructure crates implement them. - Event sourcing built in. Aggregates emit events, the engine persists them, and an upcasting chain handles schema evolution without touching historical data.
- CQRS by default. Separate
CommandBusandQueryBuswith type-safe handler registration. - Procedural macros that disappear.
#[entity],#[entity_id],#[domain_event], and#[value_object]remove the boilerplate so the business invariants stay readable. - Async-native. Tokio-based event engine with cooperative dispatch, retry, and dead-letter handling.
- No vendor lock-in. The domain crate has zero database dependencies; pick (or write) the infrastructure adapter you need.
Documentation
- API reference: https://docs.rs/eventide
- Workspace overview: GitHub
- Examples: see the
examples/directory in each sub-crate.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.