Skip to content

Commit 0d0b2f8

Browse files
Rename '*PublisherBatchLoader' to 'BatchPublisher'
This keeps in line with the original suggestion (because yours truly couldn't read, apparently). We also purge any remaining mention of 'observer', which was the first swing at this code.
1 parent b2a662d commit 0d0b2f8

11 files changed

+75
-75
lines changed

src/main/java/org/dataloader/PublisherBatchLoader.java renamed to src/main/java/org/dataloader/BatchPublisher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
* @param <K> type parameter indicating the type of keys to use for data load requests.
1717
* @param <V> type parameter indicating the type of values returned
1818
*/
19-
public interface PublisherBatchLoader<K, V> {
19+
public interface BatchPublisher<K, V> {
2020
void load(List<K> keys, Subscriber<V> subscriber);
2121
}

src/main/java/org/dataloader/PublisherBatchLoaderWithContext.java renamed to src/main/java/org/dataloader/BatchPublisherWithContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import java.util.List;
66

77
/**
8-
* An {@link PublisherBatchLoader} with a {@link BatchLoaderEnvironment} provided as an extra parameter to {@link #load}.
8+
* An {@link BatchPublisher} with a {@link BatchLoaderEnvironment} provided as an extra parameter to {@link #load}.
99
*/
10-
public interface PublisherBatchLoaderWithContext<K, V> {
10+
public interface BatchPublisherWithContext<K, V> {
1111
void load(List<K> keys, Subscriber<V> subscriber, BatchLoaderEnvironment environment);
1212
}

src/main/java/org/dataloader/DataLoaderFactory.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public static <K, V> DataLoader<K, V> newMappedDataLoaderWithTry(MappedBatchLoad
288288
*
289289
* @return a new DataLoader
290290
*/
291-
public static <K, V> DataLoader<K, V> newPublisherDataLoader(PublisherBatchLoader<K, V> batchLoadFunction) {
291+
public static <K, V> DataLoader<K, V> newPublisherDataLoader(BatchPublisher<K, V> batchLoadFunction) {
292292
return newPublisherDataLoader(batchLoadFunction, null);
293293
}
294294

@@ -302,7 +302,7 @@ public static <K, V> DataLoader<K, V> newPublisherDataLoader(PublisherBatchLoade
302302
*
303303
* @return a new DataLoader
304304
*/
305-
public static <K, V> DataLoader<K, V> newPublisherDataLoader(PublisherBatchLoader<K, V> batchLoadFunction, DataLoaderOptions options) {
305+
public static <K, V> DataLoader<K, V> newPublisherDataLoader(BatchPublisher<K, V> batchLoadFunction, DataLoaderOptions options) {
306306
return mkDataLoader(batchLoadFunction, options);
307307
}
308308

@@ -323,7 +323,7 @@ public static <K, V> DataLoader<K, V> newPublisherDataLoader(PublisherBatchLoade
323323
*
324324
* @return a new DataLoader
325325
*/
326-
public static <K, V> DataLoader<K, V> newPublisherDataLoaderWithTry(PublisherBatchLoader<K, Try<V>> batchLoadFunction) {
326+
public static <K, V> DataLoader<K, V> newPublisherDataLoaderWithTry(BatchPublisher<K, Try<V>> batchLoadFunction) {
327327
return newPublisherDataLoaderWithTry(batchLoadFunction, null);
328328
}
329329

@@ -341,7 +341,7 @@ public static <K, V> DataLoader<K, V> newPublisherDataLoaderWithTry(PublisherBat
341341
*
342342
* @see #newDataLoaderWithTry(BatchLoader)
343343
*/
344-
public static <K, V> DataLoader<K, V> newPublisherDataLoaderWithTry(PublisherBatchLoader<K, Try<V>> batchLoadFunction, DataLoaderOptions options) {
344+
public static <K, V> DataLoader<K, V> newPublisherDataLoaderWithTry(BatchPublisher<K, Try<V>> batchLoadFunction, DataLoaderOptions options) {
345345
return mkDataLoader(batchLoadFunction, options);
346346
}
347347

@@ -355,7 +355,7 @@ public static <K, V> DataLoader<K, V> newPublisherDataLoaderWithTry(PublisherBat
355355
*
356356
* @return a new DataLoader
357357
*/
358-
public static <K, V> DataLoader<K, V> newPublisherDataLoader(PublisherBatchLoaderWithContext<K, V> batchLoadFunction) {
358+
public static <K, V> DataLoader<K, V> newPublisherDataLoader(BatchPublisherWithContext<K, V> batchLoadFunction) {
359359
return newPublisherDataLoader(batchLoadFunction, null);
360360
}
361361

@@ -369,7 +369,7 @@ public static <K, V> DataLoader<K, V> newPublisherDataLoader(PublisherBatchLoade
369369
*
370370
* @return a new DataLoader
371371
*/
372-
public static <K, V> DataLoader<K, V> newPublisherDataLoader(PublisherBatchLoaderWithContext<K, V> batchLoadFunction, DataLoaderOptions options) {
372+
public static <K, V> DataLoader<K, V> newPublisherDataLoader(BatchPublisherWithContext<K, V> batchLoadFunction, DataLoaderOptions options) {
373373
return mkDataLoader(batchLoadFunction, options);
374374
}
375375

@@ -390,7 +390,7 @@ public static <K, V> DataLoader<K, V> newPublisherDataLoader(PublisherBatchLoade
390390
*
391391
* @return a new DataLoader
392392
*/
393-
public static <K, V> DataLoader<K, V> newPublisherDataLoaderWithTry(PublisherBatchLoaderWithContext<K, Try<V>> batchLoadFunction) {
393+
public static <K, V> DataLoader<K, V> newPublisherDataLoaderWithTry(BatchPublisherWithContext<K, Try<V>> batchLoadFunction) {
394394
return newPublisherDataLoaderWithTry(batchLoadFunction, null);
395395
}
396396

@@ -406,9 +406,9 @@ public static <K, V> DataLoader<K, V> newPublisherDataLoaderWithTry(PublisherBat
406406
*
407407
* @return a new DataLoader
408408
*
409-
* @see #newPublisherDataLoaderWithTry(PublisherBatchLoader)
409+
* @see #newPublisherDataLoaderWithTry(BatchPublisher)
410410
*/
411-
public static <K, V> DataLoader<K, V> newPublisherDataLoaderWithTry(PublisherBatchLoaderWithContext<K, Try<V>> batchLoadFunction, DataLoaderOptions options) {
411+
public static <K, V> DataLoader<K, V> newPublisherDataLoaderWithTry(BatchPublisherWithContext<K, Try<V>> batchLoadFunction, DataLoaderOptions options) {
412412
return mkDataLoader(batchLoadFunction, options);
413413
}
414414

@@ -422,7 +422,7 @@ public static <K, V> DataLoader<K, V> newPublisherDataLoaderWithTry(PublisherBat
422422
*
423423
* @return a new DataLoader
424424
*/
425-
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoader(MappedPublisherBatchLoader<K, V> batchLoadFunction) {
425+
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoader(MappedBatchPublisher<K, V> batchLoadFunction) {
426426
return newMappedPublisherDataLoader(batchLoadFunction, null);
427427
}
428428

@@ -436,7 +436,7 @@ public static <K, V> DataLoader<K, V> newMappedPublisherDataLoader(MappedPublish
436436
*
437437
* @return a new DataLoader
438438
*/
439-
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoader(MappedPublisherBatchLoader<K, V> batchLoadFunction, DataLoaderOptions options) {
439+
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoader(MappedBatchPublisher<K, V> batchLoadFunction, DataLoaderOptions options) {
440440
return mkDataLoader(batchLoadFunction, options);
441441
}
442442

@@ -457,7 +457,7 @@ public static <K, V> DataLoader<K, V> newMappedPublisherDataLoader(MappedPublish
457457
*
458458
* @return a new DataLoader
459459
*/
460-
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoaderWithTry(MappedPublisherBatchLoader<K, Try<V>> batchLoadFunction) {
460+
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoaderWithTry(MappedBatchPublisher<K, Try<V>> batchLoadFunction) {
461461
return newMappedPublisherDataLoaderWithTry(batchLoadFunction, null);
462462
}
463463

@@ -475,7 +475,7 @@ public static <K, V> DataLoader<K, V> newMappedPublisherDataLoaderWithTry(Mapped
475475
*
476476
* @see #newDataLoaderWithTry(BatchLoader)
477477
*/
478-
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoaderWithTry(MappedPublisherBatchLoader<K, Try<V>> batchLoadFunction, DataLoaderOptions options) {
478+
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoaderWithTry(MappedBatchPublisher<K, Try<V>> batchLoadFunction, DataLoaderOptions options) {
479479
return mkDataLoader(batchLoadFunction, options);
480480
}
481481

@@ -489,7 +489,7 @@ public static <K, V> DataLoader<K, V> newMappedPublisherDataLoaderWithTry(Mapped
489489
*
490490
* @return a new DataLoader
491491
*/
492-
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoader(MappedPublisherBatchLoaderWithContext<K, V> batchLoadFunction) {
492+
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoader(MappedBatchPublisherWithContext<K, V> batchLoadFunction) {
493493
return newMappedPublisherDataLoader(batchLoadFunction, null);
494494
}
495495

@@ -503,7 +503,7 @@ public static <K, V> DataLoader<K, V> newMappedPublisherDataLoader(MappedPublish
503503
*
504504
* @return a new DataLoader
505505
*/
506-
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoader(MappedPublisherBatchLoaderWithContext<K, V> batchLoadFunction, DataLoaderOptions options) {
506+
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoader(MappedBatchPublisherWithContext<K, V> batchLoadFunction, DataLoaderOptions options) {
507507
return mkDataLoader(batchLoadFunction, options);
508508
}
509509

@@ -524,7 +524,7 @@ public static <K, V> DataLoader<K, V> newMappedPublisherDataLoader(MappedPublish
524524
*
525525
* @return a new DataLoader
526526
*/
527-
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoaderWithTry(MappedPublisherBatchLoaderWithContext<K, Try<V>> batchLoadFunction) {
527+
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoaderWithTry(MappedBatchPublisherWithContext<K, Try<V>> batchLoadFunction) {
528528
return newMappedPublisherDataLoaderWithTry(batchLoadFunction, null);
529529
}
530530

@@ -540,9 +540,9 @@ public static <K, V> DataLoader<K, V> newMappedPublisherDataLoaderWithTry(Mapped
540540
*
541541
* @return a new DataLoader
542542
*
543-
* @see #newMappedPublisherDataLoaderWithTry(MappedPublisherBatchLoader)
543+
* @see #newMappedPublisherDataLoaderWithTry(MappedBatchPublisher)
544544
*/
545-
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoaderWithTry(MappedPublisherBatchLoaderWithContext<K, Try<V>> batchLoadFunction, DataLoaderOptions options) {
545+
public static <K, V> DataLoader<K, V> newMappedPublisherDataLoaderWithTry(MappedBatchPublisherWithContext<K, Try<V>> batchLoadFunction, DataLoaderOptions options) {
546546
return mkDataLoader(batchLoadFunction, options);
547547
}
548548

src/main/java/org/dataloader/DataLoaderHelper.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ private CompletableFuture<List<V>> dispatchQueueBatch(List<K> keys, List<Object>
248248
return batchLoad
249249
.thenApply(values -> {
250250
assertResultSize(keys, values);
251-
if (isPublisherLoader() || isMappedPublisherLoader()) {
251+
if (isPublisher() || isMappedPublisher()) {
252252
// We have already completed the queued futures by the time the overall batchLoad future has completed.
253253
return values;
254254
}
@@ -430,10 +430,10 @@ CompletableFuture<List<V>> invokeLoader(List<K> keys, List<Object> keyContexts,
430430
.context(context).keyContexts(keys, keyContexts).build();
431431
if (isMapLoader()) {
432432
batchLoad = invokeMapBatchLoader(keys, environment);
433-
} else if (isPublisherLoader()) {
434-
batchLoad = invokePublisherBatchLoader(keys, keyContexts, queuedFutures, environment);
435-
} else if (isMappedPublisherLoader()) {
436-
batchLoad = invokeMappedPublisherBatchLoader(keys, keyContexts, queuedFutures, environment);
433+
} else if (isPublisher()) {
434+
batchLoad = invokeBatchPublisher(keys, keyContexts, queuedFutures, environment);
435+
} else if (isMappedPublisher()) {
436+
batchLoad = invokeMappedBatchPublisher(keys, keyContexts, queuedFutures, environment);
437437
} else {
438438
batchLoad = invokeListBatchLoader(keys, environment);
439439
}
@@ -505,51 +505,51 @@ private CompletableFuture<List<V>> invokeMapBatchLoader(List<K> keys, BatchLoade
505505
});
506506
}
507507

508-
private CompletableFuture<List<V>> invokePublisherBatchLoader(List<K> keys, List<Object> keyContexts, List<CompletableFuture<V>> queuedFutures, BatchLoaderEnvironment environment) {
508+
private CompletableFuture<List<V>> invokeBatchPublisher(List<K> keys, List<Object> keyContexts, List<CompletableFuture<V>> queuedFutures, BatchLoaderEnvironment environment) {
509509
CompletableFuture<List<V>> loadResult = new CompletableFuture<>();
510510
Subscriber<V> subscriber = new DataLoaderSubscriber(loadResult, keys, keyContexts, queuedFutures);
511511

512512
BatchLoaderScheduler batchLoaderScheduler = loaderOptions.getBatchLoaderScheduler();
513-
if (batchLoadFunction instanceof PublisherBatchLoaderWithContext) {
514-
PublisherBatchLoaderWithContext<K, V> loadFunction = (PublisherBatchLoaderWithContext<K, V>) batchLoadFunction;
513+
if (batchLoadFunction instanceof BatchPublisherWithContext) {
514+
BatchPublisherWithContext<K, V> loadFunction = (BatchPublisherWithContext<K, V>) batchLoadFunction;
515515
if (batchLoaderScheduler != null) {
516-
BatchLoaderScheduler.ScheduledObserverBatchLoaderCall loadCall = () -> loadFunction.load(keys, subscriber, environment);
517-
batchLoaderScheduler.scheduleObserverBatchLoader(loadCall, keys, environment);
516+
BatchLoaderScheduler.ScheduledBatchPublisherCall loadCall = () -> loadFunction.load(keys, subscriber, environment);
517+
batchLoaderScheduler.scheduleBatchPublisher(loadCall, keys, environment);
518518
} else {
519519
loadFunction.load(keys, subscriber, environment);
520520
}
521521
} else {
522-
PublisherBatchLoader<K, V> loadFunction = (PublisherBatchLoader<K, V>) batchLoadFunction;
522+
BatchPublisher<K, V> loadFunction = (BatchPublisher<K, V>) batchLoadFunction;
523523
if (batchLoaderScheduler != null) {
524-
BatchLoaderScheduler.ScheduledObserverBatchLoaderCall loadCall = () -> loadFunction.load(keys, subscriber);
525-
batchLoaderScheduler.scheduleObserverBatchLoader(loadCall, keys, null);
524+
BatchLoaderScheduler.ScheduledBatchPublisherCall loadCall = () -> loadFunction.load(keys, subscriber);
525+
batchLoaderScheduler.scheduleBatchPublisher(loadCall, keys, null);
526526
} else {
527527
loadFunction.load(keys, subscriber);
528528
}
529529
}
530530
return loadResult;
531531
}
532532

533-
private CompletableFuture<List<V>> invokeMappedPublisherBatchLoader(List<K> keys, List<Object> keyContexts, List<CompletableFuture<V>> queuedFutures, BatchLoaderEnvironment environment) {
533+
private CompletableFuture<List<V>> invokeMappedBatchPublisher(List<K> keys, List<Object> keyContexts, List<CompletableFuture<V>> queuedFutures, BatchLoaderEnvironment environment) {
534534
CompletableFuture<List<V>> loadResult = new CompletableFuture<>();
535-
Subscriber<Map.Entry<K, V>> observer = new DataLoaderMapEntrySubscriber(loadResult, keys, keyContexts, queuedFutures);
535+
Subscriber<Map.Entry<K, V>> subscriber = new DataLoaderMapEntrySubscriber(loadResult, keys, keyContexts, queuedFutures);
536536

537537
BatchLoaderScheduler batchLoaderScheduler = loaderOptions.getBatchLoaderScheduler();
538-
if (batchLoadFunction instanceof MappedPublisherBatchLoaderWithContext) {
539-
MappedPublisherBatchLoaderWithContext<K, V> loadFunction = (MappedPublisherBatchLoaderWithContext<K, V>) batchLoadFunction;
538+
if (batchLoadFunction instanceof MappedBatchPublisherWithContext) {
539+
MappedBatchPublisherWithContext<K, V> loadFunction = (MappedBatchPublisherWithContext<K, V>) batchLoadFunction;
540540
if (batchLoaderScheduler != null) {
541-
BatchLoaderScheduler.ScheduledObserverBatchLoaderCall loadCall = () -> loadFunction.load(keys, observer, environment);
542-
batchLoaderScheduler.scheduleObserverBatchLoader(loadCall, keys, environment);
541+
BatchLoaderScheduler.ScheduledBatchPublisherCall loadCall = () -> loadFunction.load(keys, subscriber, environment);
542+
batchLoaderScheduler.scheduleBatchPublisher(loadCall, keys, environment);
543543
} else {
544-
loadFunction.load(keys, observer, environment);
544+
loadFunction.load(keys, subscriber, environment);
545545
}
546546
} else {
547-
MappedPublisherBatchLoader<K, V> loadFunction = (MappedPublisherBatchLoader<K, V>) batchLoadFunction;
547+
MappedBatchPublisher<K, V> loadFunction = (MappedBatchPublisher<K, V>) batchLoadFunction;
548548
if (batchLoaderScheduler != null) {
549-
BatchLoaderScheduler.ScheduledObserverBatchLoaderCall loadCall = () -> loadFunction.load(keys, observer);
550-
batchLoaderScheduler.scheduleObserverBatchLoader(loadCall, keys, null);
549+
BatchLoaderScheduler.ScheduledBatchPublisherCall loadCall = () -> loadFunction.load(keys, subscriber);
550+
batchLoaderScheduler.scheduleBatchPublisher(loadCall, keys, null);
551551
} else {
552-
loadFunction.load(keys, observer);
552+
loadFunction.load(keys, subscriber);
553553
}
554554
}
555555
return loadResult;
@@ -559,12 +559,12 @@ private boolean isMapLoader() {
559559
return batchLoadFunction instanceof MappedBatchLoader || batchLoadFunction instanceof MappedBatchLoaderWithContext;
560560
}
561561

562-
private boolean isPublisherLoader() {
563-
return batchLoadFunction instanceof PublisherBatchLoader;
562+
private boolean isPublisher() {
563+
return batchLoadFunction instanceof BatchPublisher;
564564
}
565565

566-
private boolean isMappedPublisherLoader() {
567-
return batchLoadFunction instanceof MappedPublisherBatchLoader;
566+
private boolean isMappedPublisher() {
567+
return batchLoadFunction instanceof MappedBatchPublisher;
568568
}
569569

570570
int dispatchDepth() {

src/main/java/org/dataloader/MappedPublisherBatchLoader.java renamed to src/main/java/org/dataloader/MappedBatchPublisher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
* @param <K> type parameter indicating the type of keys to use for data load requests.
1616
* @param <V> type parameter indicating the type of values returned
1717
*/
18-
public interface MappedPublisherBatchLoader<K, V> {
18+
public interface MappedBatchPublisher<K, V> {
1919
void load(List<K> keys, Subscriber<Map.Entry<K, V>> subscriber);
2020
}

src/main/java/org/dataloader/MappedPublisherBatchLoaderWithContext.java renamed to src/main/java/org/dataloader/MappedBatchPublisherWithContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import java.util.Map;
77

88
/**
9-
* A {@link MappedPublisherBatchLoader} with a {@link BatchLoaderEnvironment} provided as an extra parameter to {@link #load}.
9+
* A {@link MappedBatchPublisher} with a {@link BatchLoaderEnvironment} provided as an extra parameter to {@link #load}.
1010
*/
11-
public interface MappedPublisherBatchLoaderWithContext<K, V> {
11+
public interface MappedBatchPublisherWithContext<K, V> {
1212
void load(List<K> keys, Subscriber<Map.Entry<K, V>> subscriber, BatchLoaderEnvironment environment);
1313
}

src/main/java/org/dataloader/scheduler/BatchLoaderScheduler.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import org.dataloader.DataLoader;
66
import org.dataloader.DataLoaderOptions;
77
import org.dataloader.MappedBatchLoader;
8-
import org.dataloader.MappedPublisherBatchLoader;
9-
import org.dataloader.PublisherBatchLoader;
8+
import org.dataloader.MappedBatchPublisher;
9+
import org.dataloader.BatchPublisher;
1010

1111
import java.util.List;
1212
import java.util.Map;
@@ -45,9 +45,9 @@ interface ScheduledMappedBatchLoaderCall<K, V> {
4545
}
4646

4747
/**
48-
* This represents a callback that will invoke a {@link PublisherBatchLoader} or {@link MappedPublisherBatchLoader} function under the covers
48+
* This represents a callback that will invoke a {@link BatchPublisher} or {@link MappedBatchPublisher} function under the covers
4949
*/
50-
interface ScheduledObserverBatchLoaderCall {
50+
interface ScheduledBatchPublisherCall {
5151
void invoke();
5252
}
5353

@@ -82,14 +82,14 @@ interface ScheduledObserverBatchLoaderCall {
8282
<K, V> CompletionStage<Map<K, V>> scheduleMappedBatchLoader(ScheduledMappedBatchLoaderCall<K, V> scheduledCall, List<K> keys, BatchLoaderEnvironment environment);
8383

8484
/**
85-
* This is called to schedule a {@link PublisherBatchLoader} call.
85+
* This is called to schedule a {@link BatchPublisher} call.
8686
*
87-
* @param scheduledCall the callback that needs to be invoked to allow the {@link PublisherBatchLoader} to proceed.
88-
* @param keys this is the list of keys that will be passed to the {@link PublisherBatchLoader}.
87+
* @param scheduledCall the callback that needs to be invoked to allow the {@link BatchPublisher} to proceed.
88+
* @param keys this is the list of keys that will be passed to the {@link BatchPublisher}.
8989
* This is provided only for informative reasons and, you can't change the keys that are used
9090
* @param environment this is the {@link BatchLoaderEnvironment} in place,
91-
* which can be null if it's a simple {@link PublisherBatchLoader} call
91+
* which can be null if it's a simple {@link BatchPublisher} call
9292
* @param <K> the key type
9393
*/
94-
<K> void scheduleObserverBatchLoader(ScheduledObserverBatchLoaderCall scheduledCall, List<K> keys, BatchLoaderEnvironment environment);
94+
<K> void scheduleBatchPublisher(ScheduledBatchPublisherCall scheduledCall, List<K> keys, BatchLoaderEnvironment environment);
9595
}

0 commit comments

Comments
 (0)