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 interfaceThis represents a callback that will invoke aBatchLoaderfunction under the coversstatic interfaceThis represents a callback that will invoke aBatchPublisherorMappedBatchPublisherfunction under the coversstatic interfaceThis represents a callback that will invoke aMappedBatchLoaderfunction 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 aBatchLoadercall.<K> voidscheduleBatchPublisher(BatchLoaderScheduler.ScheduledBatchPublisherCall scheduledCall, List<K> keys, BatchLoaderEnvironment environment) This is called to schedule aBatchPublishercall.<K,V> CompletionStage<Map<K, V>> scheduleMappedBatchLoader(BatchLoaderScheduler.ScheduledMappedBatchLoaderCall<K, V> scheduledCall, List<K> keys, BatchLoaderEnvironment environment) This is called to schedule aMappedBatchLoadercall.
-
Method Details
-
scheduleBatchLoader
<K,V> CompletionStage<List<V>> scheduleBatchLoader(BatchLoaderScheduler.ScheduledBatchLoaderCall<V> scheduledCall, List<K> keys, BatchLoaderEnvironment environment) This is called to schedule aBatchLoadercall.- Type Parameters:
K- the key typeV- the value type- Parameters:
scheduledCall- the callback that needs to be invoked to allow theBatchLoaderto 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 theBatchLoaderEnvironmentin place, which can be null if it's a simpleBatchLoadercall- 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 aMappedBatchLoadercall.- Type Parameters:
K- the key typeV- the value type- Parameters:
scheduledCall- the callback that needs to be invoked to allow theMappedBatchLoaderto 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 theBatchLoaderEnvironmentin place, which can be null if it's a simpleMappedBatchLoadercall- 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 aBatchPublishercall.- Type Parameters:
K- the key type- Parameters:
scheduledCall- the callback that needs to be invoked to allow theBatchPublisherto 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 theBatchLoaderEnvironmentin place, which can be null if it's a simpleBatchPublishercall
-