Interface AuditEventStore

All Known Implementing Classes:
InMemoryAuditEventStore

@ExperimentalJSentinelApi public interface AuditEventStore
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 Type
    Method
    Description
    append(TenantId tenant, AuditEvent event)
    Persists an audit event under the given tenant scope and returns the resulting envelope (including the store-assigned identifier).
    int
    Drops every persisted envelope whose underlying event predates cutoff, for retention purposes.
    query(TenantId tenant, AuditQuery query)
    Returns every persisted envelope under tenant that matches query, in insertion order (oldest first).
  • Method Details

    • append

      AuditEnvelope append(TenantId tenant, AuditEvent event)
      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 be null
      event - audit event; must not be null
      Returns:
      the persisted envelope, never null
    • query

      List<AuditEnvelope> query(TenantId tenant, AuditQuery query)
      Returns every persisted envelope under tenant that matches query, in insertion order (oldest first).
      Parameters:
      tenant - tenant scope; must not be null
      query - match filter; must not be null. AuditQuery.all() returns every event.
      Returns:
      immutable list of matching envelopes; empty when none match
    • purgeOlderThan

      int purgeOlderThan(Instant cutoff)
      Drops every persisted envelope whose underlying event predates cutoff, for retention purposes. Implementations that do not support retention may treat this as a no-op (and document it).
      Parameters:
      cutoff - retention boundary; events with event.timestamp().isBefore(cutoff) are removed
      Returns:
      number of envelopes purged