Skip to main content

Crate eventide

Crate eventide 

Source
Expand description

§Eventide

A pragmatic Rust toolkit for Domain-Driven Design with first-class support for event sourcing and CQRS.

This umbrella crate re-exports the three building blocks that make up the toolkit so you can depend on a single crate and pull in everything you need:

ModuleSource cratePurpose
domaineventide-domainAggregates, entities, value objects, events, repositories.
applicationeventide-applicationCommand bus, query bus, handlers, application context.
macroseventide-macros#[entity], #[entity_id], #[domain_event], #[value_object].

§Quick start

Add the crate to your Cargo.toml:

[dependencies]
eventide = "0.1"
serde = { version = "1", features = ["derive"] }

Then bring the most common items into scope through the prelude:

use eventide::prelude::*;

#[entity_id]
struct UserId(String);

#[entity(id = UserId)]
#[derive(Clone, Default)]
struct User {
    name: String,
}

§Feature flags

All flags are enabled by default. Disable them selectively with default-features = false to trim the dependency tree.

  • eventing (default) — pull in eventide_domain::eventing, the asynchronous event bus / engine / dispatcher built on top of tokio.
  • macros (default) — re-export eventide_macros as macros.
  • application (default) — re-export eventide_application as application.
  • infra-sqlx — opt-in sqlx conversions on serialized events and snapshots so infrastructure crates can talk to a Postgres-backed event store without forcing a database driver into the domain layer.

§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

Domain code never depends on application or infrastructure types, which keeps your business logic pure and easy to test.

Re-exports§

pub use eventide_domain as domain;
pub use eventide_domain::async_trait;
pub use eventide_domain::tokio;eventing
pub use eventide_application as application;application
pub use eventide_macros as macros;macros

Modules§

prelude
Curated set of imports that cover the day-to-day needs of writing aggregates, events, commands and queries.

Attribute Macros§

async_trait
Re-export of the [async_trait] crate so users can write #[async_trait] on their own trait impls (e.g. domain::domain_service::DomainService, domain::eventing::EventHandler) without adding a direct async-trait dependency.