Package com.tnsai.accountability
Class RecordingLiabilitySink
java.lang.Object
com.tnsai.accountability.RecordingLiabilitySink
- All Implemented Interfaces:
LiabilitySink
In-memory
LiabilitySink for tests and assertions (TNS-298).
Holds every record in a list; tests verify production code emitted
the right liability shape via records, recordCount(),
lastRecord().
Concurrency
Backed by aReentrantReadWriteLock so concurrent dispatch
threads don't lose records under contention. Test code typically
doesn't hit that path; the lock is cheap when uncontended.
Append-only contract
Records aren't editable through this surface.clear() is
provided for test isolation (set up / tear down between cases) and
intentionally lives outside the LiabilitySink interface so
production sinks don't see it.- Since:
- 0.10.0 (TNS-298)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Test helper: drop every record.Test helper: most recent record, or empty when none recorded.query(AuditQuery q) Stream records matchingqin invocation-order (oldest first).voidPersist a record.intTest helper: how many records have been recorded.records()
-
Constructor Details
-
RecordingLiabilitySink
public RecordingLiabilitySink()
-
-
Method Details
-
record
Description copied from interface:LiabilitySinkPersist a record. Returns when the entry is durable in the implementation's backing store. Implementations MUST NOT swallow exceptions — a sink failure under load is an operational incident that needs to surface.- Specified by:
recordin interfaceLiabilitySink
-
query
Description copied from interface:LiabilitySinkStream records matchingqin invocation-order (oldest first). Stream MUST be closed by the caller — durable sinks may hold a cursor open.- Specified by:
queryin interfaceLiabilitySink
-
records
- Returns:
- defensive copy of every record so far.
-
recordCount
public int recordCount()Test helper: how many records have been recorded. -
lastRecord
Test helper: most recent record, or empty when none recorded. -
clear
public void clear()Test helper: drop every record.
-