Help us shape the future of Go! Take the 2026 Go Developer Survey

audit

package
v1.4.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func With

func With(ctx context.Context, c Ctx) context.Context

Types

type Ctx

type Ctx struct {
	ActorUserID *int64
	ActorName   string
	ActorSource string
	IP          string
	RequestID   string
}

func From

func From(ctx context.Context) Ctx

type Pruner

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

Pruner periodically deletes audit_log rows older than the configured retention.

func NewPruner

func NewPruner(s *store.Store, interval time.Duration) *Pruner

NewPruner creates a Pruner. Pass interval=0 to disable the Loop.

func (*Pruner) Loop

func (p *Pruner) Loop(ctx context.Context)

Loop runs RunOnce at every tick until ctx is cancelled. No-ops if interval <= 0.

func (*Pruner) RunOnce

func (p *Pruner) RunOnce(ctx context.Context) error

RunOnce reads retention config and prunes if enabled (days > 0).

type Publisher

type Publisher interface {
	Publish(ctx context.Context, e events.Event)
}

Publisher is the minimal interface the recorder needs to fan out realtime notifications. *events.Bus satisfies it. Optional: a nil publisher disables realtime emission without affecting audit_log writes.

type RecordReq

type RecordReq struct {
	AppID            *int64
	AppSlug          string
	Category         string
	Action           string
	Before           []byte
	After            []byte
	Error            string
	ComposeVersionID *int64
}

RecordReq is the input to Recorder.Record.

type Recorder

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

Recorder writes audit events to the DB-backed audit_log table.

func NewRecorder

func NewRecorder(s *store.Store) *Recorder

NewRecorder creates a Recorder backed by the given store.

func (*Recorder) Record

func (r *Recorder) Record(ctx context.Context, req RecordReq) (int64, error)

Record persists a single audit event. It is a no-op when r is nil.

func (*Recorder) SetBus

func (r *Recorder) SetBus(b Publisher)

SetBus wires an optional realtime event publisher. nil disables emission. Bus errors never block or fail the originating mutation.

Directories

Path Synopsis
Package render pre-renders human-readable summaries for audit events at write time; the rendered string is stored directly in the audit_log row.
Package render pre-renders human-readable summaries for audit events at write time; the rendered string is stored directly in the audit_log row.

Jump to

Keyboard shortcuts

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