| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| package graphql.execution.instrumentation.dataloader; | ||
|
|
||
|
|
||
| import graphql.ExperimentalApi; | ||
| import graphql.GraphQLContext; | ||
| import org.jspecify.annotations.NullMarked; | ||
|
|
||
| import java.time.Duration; | ||
|
|
||
| /** | ||
| * GraphQLContext keys related to DataLoader dispatching. | ||
| */ | ||
| @ExperimentalApi | ||
| @NullMarked | ||
| public final class DataLoaderDispatchingContextKeys { | ||
| private DataLoaderDispatchingContextKeys() { | ||
| } | ||
|
|
||
| /** | ||
| * In nano seconds, the batch window size for delayed DataLoaders. | ||
| * That is for DataLoaders, that are not batched as part of the normal per level | ||
| * dispatching, because they were created after the level was already dispatched. | ||
| * <p> | ||
| * Expect Long values | ||
| * <p> | ||
| * Default is 500_000 (0.5 ms) | ||
| */ | ||
| public static final String DELAYED_DATA_LOADER_BATCH_WINDOW_SIZE_NANO_SECONDS = "__GJ_delayed_data_loader_batch_window_size_nano_seconds"; | ||
|
|
||
| /** | ||
| * An instance of {@link DelayedDataLoaderDispatcherExecutorFactory} that is used to create the | ||
| * {@link java.util.concurrent.ScheduledExecutorService} for the delayed DataLoader dispatching. | ||
| * <p> | ||
| * Default is one static executor thread pool with a single thread. | ||
| */ | ||
| public static final String DELAYED_DATA_LOADER_DISPATCHING_EXECUTOR_FACTORY = "__GJ_delayed_data_loader_dispatching_executor_factory"; | ||
|
|
||
|
|
||
| /** | ||
| * Enables the ability to chain DataLoader dispatching. | ||
| * <p> | ||
| * Because this requires that all DataLoaders are accessed via DataFetchingEnvironment.getLoader() | ||
| * this is not completely backwards compatible and therefore disabled by default. | ||
| * <p> | ||
| * Expects a boolean value. | ||
| */ | ||
| public static final String ENABLE_DATA_LOADER_CHAINING = "__GJ_enable_data_loader_chaining"; | ||
|
|
||
|
|
||
| /** | ||
| * Enables the ability that chained DataLoaders are dispatched automatically. | ||
| * | ||
| * @param graphQLContext | ||
| */ | ||
| public static void setEnableDataLoaderChaining(GraphQLContext graphQLContext, boolean enabled) { | ||
| graphQLContext.put(ENABLE_DATA_LOADER_CHAINING, enabled); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Sets nanoseconds the batch window duration size for delayed DataLoaders. | ||
| * That is for DataLoaders, that are not batched as part of the normal per level | ||
| * dispatching, because they were created after the level was already dispatched. | ||
| * | ||
| * @param graphQLContext | ||
| * @param batchWindowSize | ||
| */ | ||
| public static void setDelayedDataLoaderBatchWindowSize(GraphQLContext graphQLContext, Duration batchWindowSize) { | ||
| graphQLContext.put(DELAYED_DATA_LOADER_BATCH_WINDOW_SIZE_NANO_SECONDS, batchWindowSize.toNanos()); | ||
| } | ||
|
|
||
| /** | ||
| * Sets the instance of {@link DelayedDataLoaderDispatcherExecutorFactory} that is used to create the | ||
| * {@link java.util.concurrent.ScheduledExecutorService} for the delayed DataLoader dispatching. | ||
| * <p> | ||
| * | ||
| * @param graphQLContext | ||
| * @param delayedDataLoaderDispatcherExecutorFactory | ||
| */ | ||
| public static void setDelayedDataLoaderDispatchingExecutorFactory(GraphQLContext graphQLContext, DelayedDataLoaderDispatcherExecutorFactory delayedDataLoaderDispatcherExecutorFactory) { | ||
| graphQLContext.put(DELAYED_DATA_LOADER_DISPATCHING_EXECUTOR_FACTORY, delayedDataLoaderDispatcherExecutorFactory); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package graphql.execution.instrumentation.dataloader; | ||
|
|
||
| import graphql.ExperimentalApi; | ||
| import graphql.GraphQLContext; | ||
| import graphql.execution.ExecutionId; | ||
| import org.jspecify.annotations.NullMarked; | ||
|
|
||
| import java.util.concurrent.ScheduledExecutorService; | ||
|
|
||
| /** | ||
| * See {@link DataLoaderDispatchingContextKeys} for how to set it. | ||
| */ | ||
| @ExperimentalApi | ||
| @NullMarked | ||
| @FunctionalInterface | ||
| public interface DelayedDataLoaderDispatcherExecutorFactory { | ||
|
|
||
| /** | ||
| * Called once per execution to create the {@link ScheduledExecutorService} for the delayed DataLoader dispatching. | ||
| * | ||
| * Will only called if needed, i.e. if there are delayed DataLoaders. | ||
| * | ||
| * @param executionId | ||
| * @param graphQLContext | ||
| * | ||
| * @return | ||
| */ | ||
| ScheduledExecutorService createExecutor(ExecutionId executionId, GraphQLContext graphQLContext); | ||
| } |
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.