Interface ProcessingBuffer<T extends com.google.protobuf.Message>

Type Parameters:
T - the type of protobuf message to store
All Known Implementing Classes:
NoOpProcessingBuffer, ProcessingBufferImpl

public interface ProcessingBuffer<T extends com.google.protobuf.Message>
Interface for a buffer that stores protobuf messages and can save them to disk. This is used for testing purposes to capture and save protobuf messages during test runs.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(T message)
    Adds a message to the buffer.
    void
    Clears all messages from the buffer.
    void
    Saves all messages in the buffer to disk using default parameters.
    void
    saveToDisk(String fileNamePrefix, int numberPrecision)
    Saves all messages in the buffer to disk to "
    void
    saveToDisk(Path location, String fileNamePrefix, int numberPrecision)
    Saves all messages in the buffer to disk.
    int
    Returns the number of messages in the buffer.
    Returns a snapshot of all items currently in the buffer.
  • Method Details

    • add

      void add(T message)
      Adds a message to the buffer. If the buffer is full, the oldest message will be removed.
      Parameters:
      message - the message to add
    • saveToDisk

      void saveToDisk()
      Saves all messages in the buffer to disk using default parameters. Default location is the current directory, default prefix is "protobuf", and default precision is 3 digits.
    • saveToDisk

      void saveToDisk(String fileNamePrefix, int numberPrecision)
      Saves all messages in the buffer to disk to "
      ./
      " directory.
      Parameters:
      fileNamePrefix - the prefix to use for the file names
      numberPrecision - the number of digits to use for the file name suffix
    • saveToDisk

      void saveToDisk(Path location, String fileNamePrefix, int numberPrecision)
      Saves all messages in the buffer to disk.
      Parameters:
      location - the directory to save the files to
      fileNamePrefix - the prefix to use for the file names
      numberPrecision - the number of digits to use for the file name suffix
    • size

      int size()
      Returns the number of messages in the buffer.
      Returns:
      the number of messages
    • clear

      void clear()
      Clears all messages from the buffer.
    • snapshot

      List<T> snapshot()
      Returns a snapshot of all items currently in the buffer. This method creates a new list to prevent external modification of the buffer. The returned list represents the buffer contents at the moment of the call. This is useful for analysis and reporting.
      Returns:
      a new list containing a snapshot of all messages in the buffer