Ledger-first write path
Command, aggregate, append, and SyncInTxn projection share one database transaction. Balances read their own writes after commit.
Open source · Go 1.24+ · MIT
go-sequent is a CQRS and event sourcing library for payments, wallets, and ledger workloads. It keeps the write path boring and correct: one transaction, context-scoped UnitOfWork, SyncInTxn projections.
go get github.com/go-sequent/go-sequent@latestInspired by Sequent’s domain loop, implemented as idiomatic Go. No Ruby database import, no web framework lock-in.
Command, aggregate, append, and SyncInTxn projection share one database transaction. Balances read their own writes after commit.
Per-stream hash chains detect tampering. Optimistic concurrency and tenant-scoped unique keys protect concurrent appends.
Decimal money, command audit metadata, idempotency keys, AuthZ hooks, and shared-schema tenancy are first-class.
No bundled HTTP server. Embed go-sequent in your process, wire PostgreSQL or memory stores, and keep ops in the CLI.
Capture intent with typed commands and finance-oriented Meta.
Decide and Apply events. State changes only in appliers.
Append with OCC, unique keys, and a per-aggregate hash chain.
Update ledger views inside the same write transaction.
Product decisions stay explicit so operators and auditors can reason about the system without hunting folklore.
tenant_iddemo, err := bank.NewDemoApp(bank.DemoOptions{
StoreFactory: memoryFactory,
Idempotency: idempotency.NewMemory,
Authorizer: bank.AllowBankCommands,
EnableTenancyMW: true,
})
ctx = tenancy.WithTenant(ctx, tenantID)
err = demo.App.Service.Execute(ctx, &bank.OpenAccount{ /* … */ })
bal, _ := demo.Projector.Balance(accountID)In-memory demo for always-on tests; Postgres sample for production-shaped balances.