PureeBufferedOutput

abstract class PureeBufferedOutput(uniqueId: String) : PureeOutput

Abstract base class for outputs that buffer logs before emitting them in batches.

PureeBufferedOutput extends the basic PureeOutput interface to provide buffering capabilities, which allows for more efficient processing of logs. Instead of emitting each log immediately, this class stores logs temporarily and emits them in batches according to configurable criteria.

Buffered outputs are lifecycle-aware and will automatically suspend and resume their flushing operations based on the application's lifecycle events.

Implementations must provide the actual emission logic by implementing the abstract emit method that handles batches of logs.

Constructors

Link copied to clipboard
constructor(uniqueId: String)

Properties

Link copied to clipboard

The base duration to wait when retrying a failed batch. Negative duration is automatically converted to absolute value.

Link copied to clipboard

The frequency interval when the buffer is flushed to be emitted in batches. Behavior is undefined if set to a negative value.

Link copied to clipboard
open var logsPerFlush: Int

The maximum number of logs in a batch.

Link copied to clipboard

If set, maximum number of bytes to include in a single flush

Link copied to clipboard
open var maxRetryCount: Int

The number of times to retry a failed batch.

Link copied to clipboard

If set to a non-null value, logs of this age will be not be processed and deleted. Behavior is undefined if set to a negative value.

Functions

Link copied to clipboard
override fun emit(log: JsonObject)

Stores the log instead of emitting immediately

abstract fun emit(logs: List<JsonObject>, onSuccess: () -> Unit, onFailed: (Throwable) -> Unit)

Emits a batch of logs to their destination.