atomr_patterns/lib.rs
1//! # atomr-patterns
2//!
3//! DDD/CQRS pattern library for atomr. Provides opinionated,
4//! ready-to-instantiate scaffolding on top of the primitives shipped by
5//! `atomr-core`, `atomr-persistence`, `atomr-persistence-query`,
6//! and `atomr-streams`.
7//!
8//! ## What's in the box
9//!
10//! | Pattern | Purpose |
11//! |---|---|
12//! | [`cqrs::CqrsPattern`] | Write-side aggregate + read-side projections (CQRS+ES) |
13//! | [`saga::SagaPattern`] | Long-running orchestration across aggregates |
14//! | [`bus::DomainEventBus`] | In-process event fan-out (cluster-wide behind `bus-cluster`) |
15//! | [`outbox::OutboxPattern`] | Reliable publish-after-persist |
16//! | [`acl::AntiCorruption`] | Translate between bounded contexts |
17//!
18//! ## Shape of a pattern instance
19//!
20//! Every pattern is configured with a fluent builder, returns a
21//! [`Topology`] fragment, and is materialized on an [`atomr_core::actor::ActorSystem`]
22//! to spawn its actors and start its streams. Typed handles come back
23//! to you for further interaction.
24//!
25//! ```ignore
26//! use atomr_patterns::prelude::*;
27//!
28//! let (builder, totals) = CqrsPattern::<Order>::builder()
29//! .name("orders")
30//! .factory(|id| Order::new(id))
31//! .journal(journal)
32//! .read_journal(read_journal)
33//! .with_reader(TotalsReader::default());
34//!
35//! let topology = builder.build()?;
36//! let h = topology.materialize(&system).await?;
37//! h.repository().send(PlaceOrder { id, sku }).await?;
38//! ```
39
40#![cfg_attr(docsrs, feature(doc_cfg))]
41#![forbid(unsafe_code)]
42
43pub mod acl;
44pub mod bus;
45pub mod cqrs;
46pub mod ddd;
47pub mod error;
48pub mod extensions;
49pub mod inbox;
50pub mod outbox;
51pub mod prelude;
52pub mod process_manager;
53pub mod reactor;
54pub mod saga;
55pub mod specification;
56pub mod topology;
57
58pub use error::PatternError;
59pub use topology::Topology;
60
61pub use ddd::{AggregateRoot, Command, DomainEvent, Entity, Repository, ValueObject};