examples/

directory
v1.1.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2026 License: Apache-2.0

README ΒΆ

go-mink Examples

Sixteen self-contained, runnable programs that show every major go-mink feature in action. Each lives in its own folder with a dedicated README explaining what it does, how to run it, and what to look for.

Most examples need zero infrastructure β€” just go run. Two use PostgreSQL (marked 🐘) and start it for you via Docker Compose.

Prerequisites

  • Go 1.25+
  • Docker (only for the 🐘 PostgreSQL examples)

Running an example

# From the repository root:
go run ./examples/basic          # in-memory examples β€” no setup

# bdd-testing is a test suite, run it with `go test`:
go test -v ./examples/bdd-testing

For the PostgreSQL examples, start infra first and stop it after:

docker compose -f docker-compose.test.yml up -d --wait
go run ./examples/cqrs-postgres
docker compose -f docker-compose.test.yml down

The adapter auto-creates its schema on first use, so there's nothing to migrate by hand.

The examples

Start here
Example What it shows Infra
basic The fundamentals β€” define events, model an aggregate, save and replay a stream β€”
cqrs Dispatch commands through a bus with a full middleware pipeline β€”
projections Turn events into queryable read models (inline & live) β€”
Core patterns
Example What it shows Infra
sagas Coordinate multi-step workflows with automatic compensation β€”
cqrs-postgres The cqrs example backed by a real PostgreSQL database 🐘
full-ecommerce Everything together β€” a realistic order-fulfillment system 🐘
Schema & serialization
Example What it shows Infra
versioning Evolve event schemas (v1 β†’ v2 β†’ v3) with upcasting β€” no DB migration β€”
msgpack Swap in MessagePack serialization for smaller, faster payloads β€”
protobuf Strongly-typed, schema-enforced Protocol Buffers serialization β€”
Security, privacy & compliance
Example What it shows Infra
encryption Field-level encryption at rest, per-tenant keys, crypto-shredding β€”
reencrypt-inplace Backfill encryption onto existing plaintext history in place (idempotent) β€”
export GDPR data export (right to access / portability) β€”
audit An immutable audit trail of every command (who/what/when/outcome) β€”
Observability & testing
Example What it shows Infra
metrics Prometheus metrics for commands and event-store operations β€”
tracing OpenTelemetry distributed tracing β€”
bdd-testing Behavior-driven aggregate tests with Given/When/Then β€”
feed-filter Read the event feed filtered by type / stream / category β€” for audit & introspection β€”

Suggested learning path

  1. basic β€” understand events, aggregates, and the event store.
  2. cqrs β€” add commands, handlers, and middleware.
  3. projections β€” build read models for queries.
  4. sagas β€” orchestrate workflows across aggregates.
  5. Pick the production concerns you care about β€” versioning, encryption, export, audit, metrics, tracing, feed-filter.
  6. full-ecommerce β€” see how it all composes into one system.

Learn more

Directories ΒΆ

Path Synopsis
Package main demonstrates the command Audit Logging middleware.
Package main demonstrates the command Audit Logging middleware.
Package main demonstrates the basic usage of go-mink for event sourcing.
Package main demonstrates the basic usage of go-mink for event sourcing.
Package main demonstrates the CQRS and Command Bus features of go-mink (Phase 2).
Package main demonstrates the CQRS and Command Bus features of go-mink (Phase 2).
Package main demonstrates Phase 2 CQRS & Command Bus features with PostgreSQL.
Package main demonstrates Phase 2 CQRS & Command Bus features with PostgreSQL.
Package main demonstrates field-level encryption in go-mink.
Package main demonstrates field-level encryption in go-mink.
Package main demonstrates GDPR data export (right to access / data portability) in go-mink.
Package main demonstrates GDPR data export (right to access / data portability) in go-mink.
Package main demonstrates filtered feed reads β€” reading the global event feed by an INDEXED axis for introspection.
Package main demonstrates filtered feed reads β€” reading the global event feed by an INDEXED axis for introspection.
Package main demonstrates a complete e-commerce order fulfillment system using go-mink.
Package main demonstrates a complete e-commerce order fulfillment system using go-mink.
Example: Metrics Middleware
Example: Metrics Middleware
Example: MessagePack Serializer
Example: MessagePack Serializer
Package main demonstrates the projection and read model features of go-mink.
Package main demonstrates the projection and read model features of go-mink.
Example: Protocol Buffers Serializer
Example: Protocol Buffers Serializer
Package main demonstrates in-place stream re-encryption β€” the historical backfill for a store that enabled field encryption AFTER it already had plaintext data.
Package main demonstrates in-place stream re-encryption β€” the historical backfill for a store that enabled field encryption AFTER it already had plaintext data.
Example: Saga (Process Manager) Pattern
Example: Saga (Process Manager) Pattern
Example: Distributed Tracing with OpenTelemetry
Example: Distributed Tracing with OpenTelemetry
Package main demonstrates event versioning and upcasting in go-mink.
Package main demonstrates event versioning and upcasting in go-mink.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL