Package ai.pipestream.common.interceptor
Class ProcessingBufferInterceptor
java.lang.Object
ai.pipestream.common.interceptor.ProcessingBufferInterceptor
Interceptor that automatically captures processing output to buffers based on @ProcessingBuffered annotation.
This interceptor: 1. Intercepts methods annotated with @ProcessingBuffered 2. Creates and manages ProcessingBuffer instances based on configuration 3. Automatically captures output documents from ProcessResponse when enabled 4. Provides seamless integration without manual buffer management
Configuration is resolved from annotation parameters, supporting config expressions. Buffers are created lazily and cached per method to avoid recreation overhead.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncaptureProcessingOutput(jakarta.interceptor.InvocationContext context) Intercepts method calls annotated with @ProcessingBuffered.static voidClears all buffers.Gets all active buffer keys (method identifiers).static ProcessingBuffer<ai.pipestream.data.v1.PipeDoc> Gets the buffer for a specific method, if it exists.static ProcessingBuffer<ai.pipestream.data.v1.PipeDoc> Gets the buffer for a specific class and method name.Gets buffer statistics for monitoring.static intGets the total number of documents across all buffers.static voidSaves all buffers to disk using their configured directories and prefixes.static booleansaveBuffer(String methodKey) Saves a specific buffer to disk.
-
Constructor Details
-
ProcessingBufferInterceptor
public ProcessingBufferInterceptor()
-
-
Method Details
-
captureProcessingOutput
public Object captureProcessingOutput(jakarta.interceptor.InvocationContext context) throws Exception Intercepts method calls annotated with @ProcessingBuffered.- Parameters:
context- The invocation context containing method and parameters- Returns:
- The original method result, with buffer capture as a side effect
- Throws:
Exception- If the original method throws an exception
-
getBuffer
Gets the buffer for a specific method, if it exists.- Parameters:
methodKey- The method key in format "ClassName.methodName"- Returns:
- The buffer for the method, or null if not found
-
getBuffer
public static ProcessingBuffer<ai.pipestream.data.v1.PipeDoc> getBuffer(String className, String methodName) Gets the buffer for a specific class and method name.- Parameters:
className- The simple class namemethodName- The method name- Returns:
- The buffer for the method, or null if not found
-
getActiveBufferKeys
Gets all active buffer keys (method identifiers).- Returns:
- Set of all method keys that have active buffers
-
getTotalCapturedDocuments
public static int getTotalCapturedDocuments()Gets the total number of documents across all buffers.- Returns:
- Total count of captured documents
-
saveAllBuffers
public static void saveAllBuffers()Saves all buffers to disk using their configured directories and prefixes. This is a future trigger capability for batch saving. -
saveBuffer
Saves a specific buffer to disk.- Parameters:
methodKey- The method key identifying the buffer- Returns:
- true if buffer was found and saved, false otherwise
-
clearAllBuffers
public static void clearAllBuffers()Clears all buffers. Useful for testing or memory management. -
getBufferStatistics
Gets buffer statistics for monitoring.- Returns:
- Map of method keys to buffer sizes
-