@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
DataLoader s |
void |
dispatchAllImmediately()
This will immediately dispatch the
DataLoader s in the registry
without testing the predicate |
int |
dispatchAllWithCount()
Similar to
DataLoaderRegistry.dispatchAll() , this calls DataLoader.dispatch() on
each of the registered DataLoader s, but returns the number of dispatches. |
int |
dispatchAllWithCountImmediately()
This will immediately dispatch the
DataLoader s 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, unregister
public void close()
close
in interface java.lang.AutoCloseable
public java.time.Duration getScheduleDuration()
ScheduledExecutorService
task will wait before checking the predicate againpublic void dispatchAll()
DataLoaderRegistry
DataLoader.dispatch()
on each of the registered
DataLoader
sdispatchAll
in class DataLoaderRegistry
public int dispatchAllWithCount()
DataLoaderRegistry
DataLoaderRegistry.dispatchAll()
, this calls DataLoader.dispatch()
on
each of the registered DataLoader
s, but returns the number of dispatches.dispatchAllWithCount
in class DataLoaderRegistry
DataLoader
s.public void dispatchAllImmediately()
DataLoader
s in the registry
without testing the predicatepublic int dispatchAllWithCountImmediately()
DataLoader
s in the registry
without testing the predicateDataLoader
s.public void rescheduleNow()
dispatchAll()
wouldpublic static ScheduledDataLoaderRegistry.Builder newScheduledRegistry()
Executors.newSingleThreadScheduledExecutor()
and a schedule duration of 10 milli seconds.ScheduledDataLoaderRegistry
s