audit

command
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package main demonstrates the command Audit Logging middleware.

This example shows:

  • Wiring AuditMiddleware into a CommandBus (with RecoveryMiddleware nested inside, so even a panicking handler is recorded as a failed audit entry)
  • Auditing successful AND failing commands
  • Skipping selected command types from the audit trail
  • Identifying the actor via WithActor on the context
  • Querying the audit trail with AuditQuery

It uses the in-memory audit store, so it runs with NO database:

go run ./examples/audit

For production, swap the in-memory store for the PostgreSQL store. The audit table is created by store.Initialize (it is NOT part of the adapter's migrations):

db, _ := sql.Open("postgres", connStr)            // import _ "github.com/lib/pq"
auditStore := postgres.NewAuditStore(db,
	postgres.WithAuditSchema("public"),
	postgres.WithAuditTable("mink_audit"),
)
_ = auditStore.Initialize(ctx)
// then: mink.AuditMiddleware(mink.DefaultAuditConfig(auditStore))

Jump to

Keyboard shortcuts

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