auditqueue

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package auditqueue is a durable, queue-backed auditlog.Recorder: Record enqueues the audit entry onto a skit queue (one cheap INSERT on the request path) and a background Worker drains it into the audit core. Use it when audit loss on a crash is unacceptable or to smooth write spikes; for the lowest latency with strict per-model ordering use auditlog.AsyncRecorder instead.

Ordering note: the queue does not guarantee per-model order across consumers. Core.Create retries on a version collision (so no row is lost), but if two changes to one model are processed out of order their stored version order can differ from real time. Run a single consumer, or use AsyncRecorder, when strict ordering matters.

Index

Constants

View Source
const Kind = "auditlog.record"

Kind is the queue task kind for audit entries.

Variables

This section is empty.

Functions

func NewWorker

func NewWorker(q queue.Queue, core *auditlog.Core, log *logger.Logger, cfg WorkerConfig) *worker.Loop

NewWorker returns a worker.Runnable that claims audit tasks and records them. Supervise it in a worker.Group. log may be nil.

Types

type Recorder

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

Recorder enqueues audit entries onto a queue. It implements auditlog.Recorder.

func NewRecorder

func NewRecorder(q queue.Queue, log *logger.Logger) *Recorder

NewRecorder builds a queue-backed recorder.

func (*Recorder) Record

func (r *Recorder) Record(ctx context.Context, entry auditlog.NewAuditLog)

Record enqueues entry as a queue task (best-effort: a failed enqueue is logged, not returned). The Worker later writes it through the audit core.

type Worker

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

Worker drains audit tasks from the queue into the audit core.

type WorkerConfig

type WorkerConfig struct {
	// Interval between polls (required, > 0).
	Interval time.Duration
	// Batch caps tasks claimed per tick (default 100).
	Batch int
}

WorkerConfig configures the queue-draining loop.

Jump to

Keyboard shortcuts

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