Interface AuditEventStore
- All Known Implementing Classes:
InMemoryAuditEventStore
Persistent counterpart to
AuditSink.
A AuditSink is a write-side fanout into logs and ring
buffers — fire-and-forget, geared at real-time diagnostics. An
AuditEventStore is a query-side persistence boundary —
events are appended with a tenant scope, get a stable id, and can
be retrieved later through an AuditQuery or a time window.
The two SPIs are independent on purpose: an application can ship audit events to both a fast in-memory ring buffer and a durable store without coupling either implementation to the other.
Implementations must be thread-safe; concurrent append
and query calls happen on every request that produces an
audit event.
-
Method Summary
Modifier and TypeMethodDescriptionappend(TenantId tenant, AuditEvent event) Persists an audit event under the given tenant scope and returns the resulting envelope (including the store-assigned identifier).intpurgeOlderThan(Instant cutoff) Drops every persisted envelope whose underlying event predatescutoff, for retention purposes.query(TenantId tenant, AuditQuery query) Returns every persisted envelope undertenantthat matchesquery, in insertion order (oldest first).
-
Method Details
-
append
Persists an audit event under the given tenant scope and returns the resulting envelope (including the store-assigned identifier).- Parameters:
tenant- tenant scope; must not benullevent- audit event; must not benull- Returns:
- the persisted envelope, never
null
-
query
Returns every persisted envelope undertenantthat matchesquery, in insertion order (oldest first).- Parameters:
tenant- tenant scope; must not benullquery- match filter; must not benull.AuditQuery.all()returns every event.- Returns:
- immutable list of matching envelopes; empty when none match
-
purgeOlderThan
Drops every persisted envelope whose underlying event predatescutoff, for retention purposes. Implementations that do not support retention may treat this as a no-op (and document it).- Parameters:
cutoff- retention boundary; events withevent.timestamp().isBefore(cutoff)are removed- Returns:
- number of envelopes purged
-