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