Documentation
¶
Index ¶
- type AuditEntry
- type AuditLogger
- type MemorySink
- func (m *MemorySink) ListByResource(_ context.Context, resourceType, resourceID string) ([]TimedEntry, error)
- func (m *MemorySink) Log(_ context.Context, entry AuditEntry) error
- func (m *MemorySink) Reset()
- func (m *MemorySink) Snapshot() []AuditEntry
- func (m *MemorySink) WithClock(now func() time.Time) *MemorySink
- type Reader
- type Sink
- type TimedEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditEntry ¶
type AuditLogger ¶
type AuditLogger struct {
// contains filtered or unexported fields
}
func NewAuditLogger ¶
func NewAuditLogger(pool *pgxpool.Pool) *AuditLogger
func NewAuditLoggerWithQuerier ¶
func NewAuditLoggerWithQuerier(pool *pgxpool.Pool, querier auditQuerier) *AuditLogger
func (*AuditLogger) List ¶
func (l *AuditLogger) List(ctx context.Context, limit, offset int) ([]AuditEntry, int, error)
func (*AuditLogger) ListByResource ¶
func (l *AuditLogger) ListByResource(ctx context.Context, resourceType, resourceID string) ([]TimedEntry, error)
ListByResource implements Reader by streaming every audit_logs row whose (resource_type, resource_id) pair matches the arguments, newest first. Used by the stack retry-history surface; kept action-agnostic so callers can filter further (retry history handler ignores non-retry actions).
func (*AuditLogger) Log ¶
func (l *AuditLogger) Log(ctx context.Context, entry AuditEntry) error
type MemorySink ¶
type MemorySink struct {
// contains filtered or unexported fields
}
MemorySink is a test-friendly Sink that appends every entry into an in-process slice instead of writing to Postgres. Safe for parallel tests: Log is mutex-protected and Snapshot returns a deep copy so callers can't race with subsequent writes.
func (*MemorySink) ListByResource ¶
func (m *MemorySink) ListByResource(_ context.Context, resourceType, resourceID string) ([]TimedEntry, error)
ListByResource implements Reader. Returns every entry whose ResourceType and ResourceID match the arguments, deep-copied so callers can mutate the result freely, sorted by Timestamp DESC.
func (*MemorySink) Log ¶
func (m *MemorySink) Log(_ context.Context, entry AuditEntry) error
Log implements Sink. Clones the AuditEntry's Details map so later mutations by the caller don't leak into the recorded snapshot.
func (*MemorySink) Reset ¶
func (m *MemorySink) Reset()
Reset clears all recorded entries — useful for re-using the same sink across multiple subtests.
func (*MemorySink) Snapshot ¶
func (m *MemorySink) Snapshot() []AuditEntry
Snapshot returns a shallow copy of all entries recorded so far. Each entry's Details map is copied so tests can mutate the result freely.
func (*MemorySink) WithClock ¶
func (m *MemorySink) WithClock(now func() time.Time) *MemorySink
WithClock overrides the timestamp source — tests use this to verify the sort order of ListByResource without relying on wall-clock spacing.
type Reader ¶
type Reader interface {
ListByResource(ctx context.Context, resourceType, resourceID string) ([]TimedEntry, error)
}
Reader exposes recorded audit events for per-resource queries. Added in the F8 follow-up so the retry-history surface can render emitted events without a separate storage path.
type Sink ¶
type Sink interface {
Log(ctx context.Context, entry AuditEntry) error
}
Sink is the minimal interface handlers and use cases depend on to emit audit entries. The production implementation is *AuditLogger (writes to Postgres via pgxpool); tests inject a capturing in-memory sink so e2e suites can assert on the emitted fields without standing up a DB.
This abstraction was added in Phase 2 of the F8 follow-up (2026-04-20) so Task 7-style E2Es could verify acknowledge_warnings / issue_codes propagation without touching the unexported auditQuerier machinery.
type TimedEntry ¶
type TimedEntry struct {
ID string
Timestamp time.Time
Entry AuditEntry
}
TimedEntry pairs an AuditEntry with the ID and Timestamp that the Reader surfaces externally. AuditEntry itself is intentionally kept lean — handlers and use cases should not need to know about recording metadata when emitting events.