Package org.dataloader.scheduler
Interface BatchLoaderScheduler
public interface BatchLoaderScheduler
By default, when
DataLoader.dispatch()
is called, the BatchLoader
/ MappedBatchLoader
function will be invoked
immediately. However, you can provide your own BatchLoaderScheduler
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 given DataLoader.dispatch()
call. The total set of keys will be sliced into batches themselves and then the BatchLoaderScheduler
will be called for
each batch of keys. Do not assume that a single call to DataLoader.dispatch()
results in a single call to BatchLoaderScheduler
.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
This represents a callback that will invoke aBatchLoader
function under the coversstatic interface
This represents a callback that will invoke aBatchPublisher
orMappedBatchPublisher
function under the coversstatic interface
This represents a callback that will invoke aMappedBatchLoader
function under the covers -
Method Summary
Modifier and TypeMethodDescription<K,
V> CompletionStage<List<V>> scheduleBatchLoader
(BatchLoaderScheduler.ScheduledBatchLoaderCall<V> scheduledCall, List<K> keys, BatchLoaderEnvironment environment) This is called to schedule aBatchLoader
call.<K> void
scheduleBatchPublisher
(BatchLoaderScheduler.ScheduledBatchPublisherCall scheduledCall, List<K> keys, BatchLoaderEnvironment environment) This is called to schedule aBatchPublisher
call.<K,
V> CompletionStage<Map<K, V>> scheduleMappedBatchLoader
(BatchLoaderScheduler.ScheduledMappedBatchLoaderCall<K, V> scheduledCall, List<K> keys, BatchLoaderEnvironment environment) This is called to schedule aMappedBatchLoader
call.
-
Method Details
-
scheduleBatchLoader
<K,V> CompletionStage<List<V>> scheduleBatchLoader(BatchLoaderScheduler.ScheduledBatchLoaderCall<V> scheduledCall, 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> CompletionStage<Map<K,V>> scheduleMappedBatchLoader(BatchLoaderScheduler.ScheduledMappedBatchLoaderCall<K, V> scheduledCall, 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, 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
-