You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CompletableFuture<Map<K, V>> mapBatchLoad = nonNull(loadResult, () -> "Your batch loader function MUST return a non null CompletionStage").toCompletableFuture();
* By default, when {@link DataLoader#dispatch()} is called, the {@link BatchLoader} / {@link MappedBatchLoader} function will be invoked
15
+
* immediately. However, you can provide your own {@link BatchLoaderScheduler} that allows this call to be done some time into
16
+
* the future. You will be passed a callback ({@link ScheduledBatchLoaderCall} / {@link ScheduledMappedBatchLoaderCall} and you are expected
17
+
* to eventually call this callback method to make the batch loading happen.
18
+
* <p>
19
+
* Note: Because there is a {@link DataLoaderOptions#maxBatchSize()} it is possible for this scheduling to happen N times for a given {@link DataLoader#dispatch()}
20
+
* call. The total set of keys will be sliced into batches themselves and then the {@link BatchLoaderScheduler} will be called for
21
+
* each batch of keys. Do not assume that a single call to {@link DataLoader#dispatch()} results in a single call to {@link BatchLoaderScheduler}.
22
+
*/
23
+
publicinterfaceBatchLoaderScheduler {
24
+
25
+
26
+
/**
27
+
* This represents a callback that will invoke a {@link BatchLoader} function under the covers
28
+
*
29
+
* @param <V> the value type
30
+
*/
31
+
interfaceScheduledBatchLoaderCall<V> {
32
+
CompletionStage<List<V>> invoke();
33
+
}
34
+
35
+
/**
36
+
* This represents a callback that will invoke a {@link MappedBatchLoader} function under the covers
37
+
*
38
+
* @param <K> the key type
39
+
* @param <V> the value type
40
+
*/
41
+
interfaceScheduledMappedBatchLoaderCall<K, V> {
42
+
CompletionStage<Map<K, V>> invoke();
43
+
}
44
+
45
+
/**
46
+
* This is called to schedule a {@link BatchLoader} call.
47
+
*
48
+
* @param scheduledCall the callback that needs to be invoked to allow the {@link BatchLoader} to proceed.
49
+
* @param keys this is the list of keys that will be passed to the {@link BatchLoader}.
50
+
* This is provided only for informative reasons and you cant change the keys that are used
51
+
* @param environment this is the {@link BatchLoaderEnvironment} in place,
52
+
* which can be null if it's a simple {@link BatchLoader} call
53
+
* @param <K> the key type
54
+
* @param <V> the value type
55
+
*
56
+
* @return a promise to the values that come from the {@link BatchLoader}
0 commit comments