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 ¶
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, error)
NewWorker returns a worker.Loop that claims audit tasks and records them via the audit core. It drives a worker.Processor (q is both Source and Sink) with a queue.Mux dispatching the audit Kind, so the claim -> handle -> ack/retry loop, retry scheduling, and dead-lettering are shared with every other queue consumer instead of hand-rolled. Supervise the returned Loop in a worker.Group. log may be nil.
It returns an error only if wiring the Mux fails — which cannot happen here, as the single registration uses a constant Kind and a non-nil handler.
Types ¶
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder enqueues audit entries onto a queue. It implements auditlog.Recorder.
func NewRecorder ¶
NewRecorder builds a queue-backed recorder.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker records claimed audit tasks 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.