Package org.dataloader.scheduler
Interface BatchLoaderScheduler
-
public interface BatchLoaderScheduler
By default, whenDataLoader.dispatch()
is called, theBatchLoader
/MappedBatchLoader
function will be invoked immediately. However, you can provide your ownBatchLoaderScheduler
that allows this call to be done some time into the future. You will be passed a callback (BatchLoaderScheduler.ScheduledBatchLoaderCall
/BatchLoaderScheduler.ScheduledMappedBatchLoaderCall
and you are expected to eventually call this callback method to make the batch loading happen.Note: Because there is a
DataLoaderOptions.maxBatchSize()
it is possible for this scheduling to happen N times for a givenDataLoader.dispatch()
call. The total set of keys will be sliced into batches themselves and then theBatchLoaderScheduler
will be called for each batch of keys. Do not assume that a single call toDataLoader.dispatch()
results in a single call toBatchLoaderScheduler
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
BatchLoaderScheduler.ScheduledBatchLoaderCall<V>
This represents a callback that will invoke aBatchLoader
function under the coversstatic interface
BatchLoaderScheduler.ScheduledBatchPublisherCall
This represents a callback that will invoke aBatchPublisher
orMappedBatchPublisher
function under the coversstatic interface
BatchLoaderScheduler.ScheduledMappedBatchLoaderCall<K,V>
This represents a callback that will invoke aMappedBatchLoader
function under the covers
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <K,V>
java.util.concurrent.CompletionStage<java.util.List<V>>scheduleBatchLoader(BatchLoaderScheduler.ScheduledBatchLoaderCall<V> scheduledCall, java.util.List<K> keys, BatchLoaderEnvironment environment)
This is called to schedule aBatchLoader
call.<K> void
scheduleBatchPublisher(BatchLoaderScheduler.ScheduledBatchPublisherCall scheduledCall, java.util.List<K> keys, BatchLoaderEnvironment environment)
This is called to schedule aBatchPublisher
call.<K,V>
java.util.concurrent.CompletionStage<java.util.Map<K,V>>scheduleMappedBatchLoader(BatchLoaderScheduler.ScheduledMappedBatchLoaderCall<K,V> scheduledCall, java.util.List<K> keys, BatchLoaderEnvironment environment)
This is called to schedule aMappedBatchLoader
call.
-
-
-
Method Detail
-
scheduleBatchLoader
<K,V> java.util.concurrent.CompletionStage<java.util.List<V>> scheduleBatchLoader(BatchLoaderScheduler.ScheduledBatchLoaderCall<V> scheduledCall, java.util.List<K> keys, BatchLoaderEnvironment environment)
This is called to schedule aBatchLoader
call.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
scheduledCall
- the callback that needs to be invoked to allow theBatchLoader
to proceed.keys
- this is the list of keys that will be passed to theBatchLoader
. This is provided only for informative reasons, and you can't change the keys that are usedenvironment
- this is theBatchLoaderEnvironment
in place, which can be null if it's a simpleBatchLoader
call- Returns:
- a promise to the values that come from the
BatchLoader
-
scheduleMappedBatchLoader
<K,V> java.util.concurrent.CompletionStage<java.util.Map<K,V>> scheduleMappedBatchLoader(BatchLoaderScheduler.ScheduledMappedBatchLoaderCall<K,V> scheduledCall, java.util.List<K> keys, BatchLoaderEnvironment environment)
This is called to schedule aMappedBatchLoader
call.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
scheduledCall
- the callback that needs to be invoked to allow theMappedBatchLoader
to proceed.keys
- this is the list of keys that will be passed to theMappedBatchLoader
. This is provided only for informative reasons and, you can't change the keys that are usedenvironment
- this is theBatchLoaderEnvironment
in place, which can be null if it's a simpleMappedBatchLoader
call- Returns:
- a promise to the values that come from the
BatchLoader
-
scheduleBatchPublisher
<K> void scheduleBatchPublisher(BatchLoaderScheduler.ScheduledBatchPublisherCall scheduledCall, java.util.List<K> keys, BatchLoaderEnvironment environment)
This is called to schedule aBatchPublisher
call.- Type Parameters:
K
- the key type- Parameters:
scheduledCall
- the callback that needs to be invoked to allow theBatchPublisher
to proceed.keys
- this is the list of keys that will be passed to theBatchPublisher
. This is provided only for informative reasons and, you can't change the keys that are usedenvironment
- this is theBatchLoaderEnvironment
in place, which can be null if it's a simpleBatchPublisher
call
-
-