Interface BatchPublisher<K,V>
-
- Type Parameters:
K
- type parameter indicating the type of keys to use for data load requests.V
- type parameter indicating the type of values returned
@NullMarked @PublicSpi public interface BatchPublisher<K,V>
A function that is invoked for batch loading a stream of data values indicated by the provided list of keys.The function must call the provided
Subscriber
to process the values it has retrieved to allow the future returned byDataLoader.load(Object)
to complete as soon as the individual value is available (rather than when all values have been retrieved).NOTE: It is required that
Subscriber.onNext(Object)
is invoked on each value in the same order as the provided keys and that you provide a value for every key provided.- See Also:
for the non-reactive version
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
load(java.util.List<K> keys, org.reactivestreams.Subscriber<V> subscriber)
Called to batch the provided keys into a stream of values.
-
-
-
Method Detail
-
load
void load(java.util.List<K> keys, org.reactivestreams.Subscriber<V> subscriber)
Called to batch the provided keys into a stream of values. You must provide the same number of values as there as keys, and they must be in the order of the keys.The idiomatic approach would be to create a reactive
Publisher
that provides the values given the keys and then subscribe to it with the providedSubscriber
.NOTE: It is required that
Subscriber.onNext(Object)
is invoked on each value in the same order as the provided keys and that you provide a value for every key provided.- Parameters:
keys
- the collection of keys to loadsubscriber
- as values arrive you must call the subscriber for each value
-
-