audit

package
v0.21.4 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package audit records who changed what.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Record

func Record(ctx context.Context, e Execer, actor, action, resource string, detail any) error

Record writes one entry through e. A nil detail stores an empty object.

Types

type AuditEntry

type AuditEntry struct {
	ID        string          `json:"id"`
	Actor     string          `json:"actor"`
	Action    string          `json:"action"`
	Resource  string          `json:"resource"`
	Detail    json.RawMessage `json:"detail"`
	CreatedAt time.Time       `json:"created_at"`
}

AuditEntry is one audit record.

func List

func List(ctx context.Context, pool *pgxpool.Pool, limit int) ([]AuditEntry, error)

List returns the newest entries first.

type Execer

type Execer interface {
	Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
}

Execer lets Record join the transaction that made the change, so a change and its record commit together.

Jump to

Keyboard shortcuts

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