Class DiagnosticQueue

java.lang.Object
io.higson.runtime.diagnostic.queue.DiagnosticQueue

public class DiagnosticQueue extends Object
Thread-safe, bounded in-memory queue for DiagnosticEvent objects.

Overflow behaviour is controlled by DiagnosticQueueConfig.getOverflowStrategy():

Thread-safety is provided entirely by LinkedBlockingDeque and DiagnosticQueueMetrics; no additional synchronized blocks are used.
  • Constructor Details

  • Method Details

    • enqueue

      public boolean enqueue(DiagnosticEvent event)
      Add an event to the queue according to the configured overflow strategy.
      Parameters:
      event - the event to enqueue; must not be null
      Returns:
      true if the event was successfully placed in the queue, false if it was dropped (DROP_NEWEST strategy)
      Throws:
      RuntimeException - wrapping InterruptedException when BLOCK strategy is used and the thread is interrupted while waiting
    • drainBatch

      public List<DiagnosticEvent> drainBatch()
      Drain up to DiagnosticQueueConfig.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

      public DiagnosticQueueMetrics getMetrics()
    • getConfig

      public DiagnosticQueueConfig getConfig()