|
7 | 7 | /**
|
8 | 8 | * A function that is invoked for batch loading a stream of data values indicated by the provided list of keys.
|
9 | 9 | * <p>
|
10 |
| - * The function will call the provided {@link Subscriber} to process the values it has retrieved to allow |
| 10 | + * The function <b>must</b> call the provided {@link Subscriber} to process the values it has retrieved to allow |
11 | 11 | * the future returned by {@link DataLoader#load(Object)} to complete as soon as the individual value is available
|
12 | 12 | * (rather than when all values have been retrieved).
|
13 | 13 | * <p>
|
14 |
| - * <b>NOTE:</b> It is <b>required </b> that {@link Subscriber#onNext(Object)} is invoked on each value in the same order as |
15 |
| - * the provided keys. |
| 14 | + * <b>NOTE:</b> It is <b>required</b> that {@link Subscriber#onNext(Object)} is invoked on each value in the same order as |
| 15 | + * the provided keys and that you provide a value for every key provided. |
16 | 16 | *
|
17 | 17 | * @param <K> type parameter indicating the type of keys to use for data load requests.
|
18 | 18 | * @param <V> type parameter indicating the type of values returned
|
| 19 | + * @see BatchLoader for the non-reactive version |
19 | 20 | */
|
20 | 21 | public interface BatchPublisher<K, V> {
|
| 22 | + /** |
| 23 | + * Called to batch the provided keys into a stream of values. You <b>must</b> provide |
| 24 | + * the same number of values as there as keys, and they <b>must</b> be in the order of the keys. |
| 25 | + * <p> |
| 26 | + * The idiomatic approach would be to create a reactive {@link org.reactivestreams.Publisher} that provides |
| 27 | + * the values given the keys and then subscribe to it with the provided {@link Subscriber}. |
| 28 | + * <p> |
| 29 | + * <b>NOTE:</b> It is <b>required</b> that {@link Subscriber#onNext(Object)} is invoked on each value in the same order as |
| 30 | + * the provided keys and that you provide a value for every key provided. |
| 31 | + * |
| 32 | + * @param keys the collection of keys to load |
| 33 | + * @param subscriber as values arrive you must call the subscriber for each value |
| 34 | + */ |
21 | 35 | void load(List<K> keys, Subscriber<V> subscriber);
|
22 | 36 | }
|
0 commit comments