Skip to main content

Crate atomr_patterns

Crate atomr_patterns 

Source
Expand description

§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

PatternPurpose
cqrs::CqrsPatternWrite-side aggregate + read-side projections (CQRS+ES)
saga::SagaPatternLong-running orchestration across aggregates
bus::DomainEventBusIn-process event fan-out (cluster-wide behind bus-cluster)
outbox::OutboxPatternReliable publish-after-persist
acl::AntiCorruptionTranslate 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.

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?;

Re-exports§

pub use error::PatternError;
pub use topology::Topology;
pub use ddd::AggregateRoot;
pub use ddd::Command;
pub use ddd::DomainEvent;
pub use ddd::Entity;
pub use ddd::Repository;
pub use ddd::ValueObject;

Modules§

acl
Anti-Corruption Layer pattern.
bus
Domain Event Bus pattern.
cqrs
CQRS + Event Sourcing pattern.
ddd
Domain-Driven-Design primitives shared by every pattern.
error
Pattern-level errors.
extensions
Extension hooks shared across patterns.
inbox
Inbox pattern — idempotent receiver for messages arriving from external sources.
outbox
Transactional Outbox pattern.
prelude
Convenient re-exports.
process_manager
Process Manager pattern — typed state-machine alternative to crate::saga::SagaPattern.
reactor
Reactor pattern — fire-and-forget side effects in response to events.
saga
Saga / Process Manager pattern.
specification
Specification pattern — composable predicates over a domain type.
topology
Topology — common materialization surface for every pattern.