Class BatchOptions.Builder
java.lang.Object
codes.grow.packages.betterstack.logging.BatchOptions.Builder
- Enclosing class:
BatchOptions
Builder for
BatchOptions.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Validates and builds the options.dropPolicy(DropPolicy dropPolicy) Sets the drop policy.exportTimeout(Duration exportTimeout) Sets the export timeout.flushInterval(Duration flushInterval) Sets the background flush interval.gzip(boolean gzip) Enables or disables gzip.maxBatchBytes(int maxBatchBytes) Sets the batch byte limit.maxBatchSize(int maxBatchSize) Sets the batch size.maxExportRetries(int maxExportRetries) Sets how often a batch is re-exported after a retryable failure.maxQueueSize(int maxQueueSize) Sets the queue size.onDrop(BiConsumer<List<LogRecord>, DropReason> onDrop) Sets the drop callback (exceptions it throws are ignored).onError(BiConsumer<Throwable, List<LogRecord>> onError) Sets the export error callback (exceptions it throws are ignored).retryBackoff(Duration retryBackoff) Sets the base retry delay (doubled per attempt).
-
Method Details
-
maxQueueSize
Sets the queue size.- Parameters:
maxQueueSize- at least 1- Returns:
- this builder
-
maxBatchSize
Sets the batch size.- Parameters:
maxBatchSize- at least 1 and at mostmaxQueueSize- Returns:
- this builder
-
maxBatchBytes
Sets the batch byte limit.- Parameters:
maxBatchBytes- at least 1- Returns:
- this builder
-
flushInterval
Sets the background flush interval.- Parameters:
flushInterval- positive duration- Returns:
- this builder
-
exportTimeout
Sets the export timeout.- Parameters:
exportTimeout- positive duration- Returns:
- this builder
-
dropPolicy
Sets the drop policy.- Parameters:
dropPolicy- policy- Returns:
- this builder
-
gzip
Enables or disables gzip.- Parameters:
gzip- gzip flag- Returns:
- this builder
-
maxExportRetries
Sets how often a batch is re-exported after a retryable failure.- Parameters:
maxExportRetries- 0 or more (default 2)- Returns:
- this builder
-
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
Validates and builds the options.- Returns:
- options
- Throws:
ConfigException- when a value is out of range
-