Skip to content

Nagare

Event sourcing for .NET

Flow in, truth out.

CommandAggregateEventProjection

A command flows in. The aggregate decides. Events are recorded. Projections reflect the truth.

Commands

Express intent. The aggregate decides what happens next.

commands
    .On<BorrowBook>((state, cmd) =>
        !state.Exists      ? Then.Reject("Book does not exist")
        : state.IsBorrowed ? Then.Reject("Already borrowed")
        : Then.Persist(new BookBorrowed(cmd.BorrowerId)));

Testing

Given events happened. When a command arrives. Then expect the outcome. No infrastructure. Just truth.

harness
    .Given(new BookAdded("Dune", "Herbert", "978-044"))
    .When(new BorrowBook("user-42"))
    .ThenAccepted()
    .ThenExpect<BookBorrowed>(
        e => e.BorrowerId == "user-42");

Commands

Express intent.
The aggregate decides.

Events

What happened is truth.
Immutable, eternal.

Projections

The stream reflects.
Many views, one source.

流れ

nagare — flow

MIT License

流れ — flow.