-
Notifications
You must be signed in to change notification settings - Fork 93
Add a proof-of-concept for "Observer-like" batch loading #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6e30220
2032e33
6b5a732
68d7f54
a3132b7
fbeffae
b2a662d
0d0b2f8
14002f6
0f303a8
ce115fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.dataloader; | ||
|
||
import org.reactivestreams.Subscriber; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* A function that is invoked for batch loading a stream of data values indicated by the provided list of keys. | ||
* <p> | ||
* The function will call the provided {@link Subscriber} to process the values it has retrieved to allow | ||
* the future returned by {@link DataLoader#load(Object)} to complete as soon as the individual value is available | ||
* (rather than when all values have been retrieved). | ||
* <p> | ||
* <b>NOTE:</b> It is <b>required </b> that {@link Subscriber#onNext(V)} is invoked on each value in the same order as | ||
* the provided keys. | ||
* | ||
* @param <K> type parameter indicating the type of keys to use for data load requests. | ||
* @param <V> type parameter indicating the type of values returned | ||
*/ | ||
public interface BatchPublisher<K, V> { | ||
void load(List<K> keys, Subscriber<V> subscriber); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the name now that we have the reactive streams There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And less interfaces needed |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.dataloader; | ||
|
||
import org.reactivestreams.Subscriber; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* An {@link BatchPublisher} with a {@link BatchLoaderEnvironment} provided as an extra parameter to {@link #load}. | ||
*/ | ||
public interface BatchPublisherWithContext<K, V> { | ||
void load(List<K> keys, Subscriber<V> subscriber, BatchLoaderEnvironment environment); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe some more explanatory text here as its so important