public final class BatcherBuilder extends Object
Batcher implementation that creates batches with one or more bounding conditions. All batchers
pass off batches to a listenerService() to allow for handling of batches asynchronously via a
BatchListener. If no listenerService() is provided then a cached thread pool will be used.| Modifier and Type | Method and Description |
|---|---|
BatcherBuilder |
bufferSize(int bufferSize)
Bound the buffer size used by the batchers.
|
<T> Batcher<T> |
build(BatchListener<T> listener)
Builds a
Batcher which will provide batches to the provided listener. |
static BatcherBuilder |
create()
Creates a new builder for creating a
Batcher. |
BatcherBuilder |
listenerService(ExecutorService listenerService)
Provide a configured
ExecutorService to use for running the BatchListener on. |
BatcherBuilder |
sizeBound(int size)
Add a max size component for a batcher.
|
BatcherBuilder |
timeBound(long time,
TimeUnit timeUnit)
Add a max time component for a batcher.
|
public static BatcherBuilder create()
Batcher.public BatcherBuilder sizeBound(int size)
BatchListener
as soon as the size bound is reached.public BatcherBuilder timeBound(long time, TimeUnit timeUnit)
BatchListener
as soon as the time bound has been exceeded.
NOTE: This interval is the time since successfully sending the last batch to the batchlistener. This means
that if a blocking listenerService(ExecutorService) is used then the time interval will not
restart until it has been successfully handed off to the listenerService(ExecutorService).public BatcherBuilder bufferSize(int bufferSize)
public BatcherBuilder listenerService(ExecutorService listenerService)
ExecutorService to use for running the BatchListener on.
This ExecutorService will be shutdown when the created batcher is closed. By default a cached
thread pool is used to handle calls to the BatchListener.public <T> Batcher<T> build(BatchListener<T> listener)
Batcher which will provide batches to the provided listener.
Note: The builder is required to have either a time or size bound to build a batch.Copyright © 2018 Calrissian. All rights reserved.