Class BatchOptions.Builder

java.lang.Object
codes.grow.packages.betterstack.logging.BatchOptions.Builder
Enclosing class:
BatchOptions

public static final class BatchOptions.Builder extends Object
Builder for BatchOptions.
  • Method Details

    • maxQueueSize

      public BatchOptions.Builder maxQueueSize(int maxQueueSize)
      Sets the queue size.
      Parameters:
      maxQueueSize - at least 1
      Returns:
      this builder
    • maxBatchSize

      public BatchOptions.Builder maxBatchSize(int maxBatchSize)
      Sets the batch size.
      Parameters:
      maxBatchSize - at least 1 and at most maxQueueSize
      Returns:
      this builder
    • maxBatchBytes

      public BatchOptions.Builder maxBatchBytes(int maxBatchBytes)
      Sets the batch byte limit.
      Parameters:
      maxBatchBytes - at least 1
      Returns:
      this builder
    • flushInterval

      public BatchOptions.Builder flushInterval(Duration flushInterval)
      Sets the background flush interval.
      Parameters:
      flushInterval - positive duration
      Returns:
      this builder
    • exportTimeout

      public BatchOptions.Builder exportTimeout(Duration exportTimeout)
      Sets the export timeout.
      Parameters:
      exportTimeout - positive duration
      Returns:
      this builder
    • dropPolicy

      public BatchOptions.Builder dropPolicy(DropPolicy dropPolicy)
      Sets the drop policy.
      Parameters:
      dropPolicy - policy
      Returns:
      this builder
    • gzip

      public BatchOptions.Builder gzip(boolean gzip)
      Enables or disables gzip.
      Parameters:
      gzip - gzip flag
      Returns:
      this builder
    • maxExportRetries

      public BatchOptions.Builder maxExportRetries(int maxExportRetries)
      Sets how often a batch is re-exported after a retryable failure.
      Parameters:
      maxExportRetries - 0 or more (default 2)
      Returns:
      this builder
    • retryBackoff

      public BatchOptions.Builder retryBackoff(Duration retryBackoff)
      Sets the base retry delay (doubled per attempt).
      Parameters:
      retryBackoff - 0 or more (default 200 ms)
      Returns:
      this builder
    • onDrop

      Sets the drop callback (exceptions it throws are ignored).
      Parameters:
      onDrop - callback receiving the dropped records and the reason
      Returns:
      this builder
    • onError

      Sets the export error callback (exceptions it throws are ignored).
      Parameters:
      onError - callback receiving the error and the affected records
      Returns:
      this builder
    • build

      public BatchOptions build()
      Validates and builds the options.
      Returns:
      options
      Throws:
      ConfigException - when a value is out of range