audit

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSVCell

func CSVCell(s string) string

func WithRequestID

func WithRequestID(ctx context.Context, id string) context.Context

Types

type ListQuery

type ListQuery struct {
	WorkspaceID   string
	ActorID       string
	Action        string
	ResourceType  string
	From, To      *time.Time
	Limit, Offset int
}

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

func NewRecorder

func NewRecorder(pool *pgxpool.Pool, log *slog.Logger) *Recorder

func (*Recorder) ExportCSV

func (r *Recorder) ExportCSV(ctx context.Context, q ListQuery, w io.Writer) error

func (*Recorder) List

func (r *Recorder) List(ctx context.Context, workspaceID string, limit int) ([]map[string]any, error)

func (*Recorder) Query

func (r *Recorder) Query(ctx context.Context, q ListQuery) ([]map[string]any, int, error)

func (*Recorder) Record

func (r *Recorder) Record(ctx context.Context, workspaceID *string, p *webx.Principal, action, resourceType, resourceID string, meta map[string]any)

func (*Recorder) RecordTx added in v0.4.0

func (r *Recorder) RecordTx(ctx context.Context, tx execer, workspaceID *string, p *webx.Principal, action, resourceType, resourceID string, meta map[string]any) error

RecordTx writes the audit entry inside the caller's transaction: failures return an error (the caller decides whether to roll back) - no swallowing, no detaching from the caller's ctx (opposite of Record's fire-and-forget). Product gates that need "business write and audit live or die together" should use this instead of hand-writing INSERT SQL (which silently decouples from schema evolution).

Directories

Path Synopsis
adapters

Jump to

Keyboard shortcuts

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