Class DiagnosticQueue
java.lang.Object
io.higson.runtime.diagnostic.queue.DiagnosticQueue
Thread-safe, bounded in-memory queue for
DiagnosticEvent objects.
Overflow behaviour is controlled by DiagnosticQueueConfig.getOverflowStrategy():
OverflowStrategy.DROP_OLDEST– removes the head element to make room.OverflowStrategy.DROP_NEWEST– silently discards the incoming event.OverflowStrategy.BLOCK– blocks the calling thread until space is available.
LinkedBlockingDeque and DiagnosticQueueMetrics;
no additional synchronized blocks are used.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Remove all events from the queue without recording them as flushed.Drain up toDiagnosticQueueConfig.getBatchSize()events from the head of the queue into a new list.booleanenqueue(DiagnosticEvent event) Add an event to the queue according to the configured overflow strategy.intsize()Return the current number of events waiting in the queue.
-
Constructor Details
-
DiagnosticQueue
-
-
Method Details
-
enqueue
Add an event to the queue according to the configured overflow strategy.- Parameters:
event- the event to enqueue; must not benull- Returns:
trueif the event was successfully placed in the queue,falseif it was dropped (DROP_NEWEST strategy)- Throws:
RuntimeException- wrappingInterruptedExceptionwhen BLOCK strategy is used and the thread is interrupted while waiting
-
drainBatch
Drain up toDiagnosticQueueConfig.getBatchSize()events from the head of the queue into a new list.- Returns:
- a list of drained events; never
null, may be empty
-
size
public int size()Return the current number of events waiting in the queue. -
clear
public void clear()Remove all events from the queue without recording them as flushed. -
getMetrics
-
getConfig
-