@ExperimentalApi public class ScheduledDataLoaderRegistry extends DataLoaderRegistry implements java.lang.AutoCloseable
DataLoaderRegistry will use a DispatchPredicate when dispatchAll() is called
to test (for each DataLoader in the registry) if a dispatch should proceed. If the predicate returns false, then a task is scheduled
to perform that predicate dispatch again via the ScheduledExecutorService.
This will continue to loop (test false and reschedule) until such time as the predicate returns true, in which case no rescheduling will occur and you will need to call dispatch again to restart the process.
If you wanted to create a ScheduledDataLoaderRegistry that started a rescheduling immediately, just create one and
call rescheduleNow().
This code is currently marked as ExperimentalApi
| Modifier and Type | Class and Description |
|---|---|
static class |
ScheduledDataLoaderRegistry.Builder |
dataLoaders| Modifier and Type | Method and Description |
|---|---|
void |
close()
Once closed this registry will never again reschedule checks
|
void |
dispatchAll()
This will called
DataLoader.dispatch() on each of the registered
DataLoaders |
void |
dispatchAllImmediately()
This will immediately dispatch the
DataLoaders in the registry
without testing the predicate |
int |
dispatchAllWithCount()
Similar to
DataLoaderRegistry.dispatchAll(), this calls DataLoader.dispatch() on
each of the registered DataLoaders, but returns the number of dispatches. |
int |
dispatchAllWithCountImmediately()
This will immediately dispatch the
DataLoaders in the registry
without testing the predicate |
java.time.Duration |
getScheduleDuration() |
static ScheduledDataLoaderRegistry.Builder |
newScheduledRegistry()
By default this will create use a
Executors.newSingleThreadScheduledExecutor()
and a schedule duration of 10 milli seconds. |
void |
rescheduleNow()
This will schedule a task to check the predicate and dispatch if true right now.
|
combine, computeIfAbsent, dispatchDepth, getDataLoader, getDataLoaders, getDataLoadersMap, getKeys, getStatistics, newRegistry, register, unregisterpublic void close()
close in interface java.lang.AutoCloseablepublic java.time.Duration getScheduleDuration()
ScheduledExecutorService task will wait before checking the predicate againpublic void dispatchAll()
DataLoaderRegistryDataLoader.dispatch() on each of the registered
DataLoadersdispatchAll in class DataLoaderRegistrypublic int dispatchAllWithCount()
DataLoaderRegistryDataLoaderRegistry.dispatchAll(), this calls DataLoader.dispatch() on
each of the registered DataLoaders, but returns the number of dispatches.dispatchAllWithCount in class DataLoaderRegistryDataLoaders.public void dispatchAllImmediately()
DataLoaders in the registry
without testing the predicatepublic int dispatchAllWithCountImmediately()
DataLoaders in the registry
without testing the predicateDataLoaders.public void rescheduleNow()
dispatchAll() wouldpublic static ScheduledDataLoaderRegistry.Builder newScheduledRegistry()
Executors.newSingleThreadScheduledExecutor()
and a schedule duration of 10 milli seconds.ScheduledDataLoaderRegistrys