graphQL = new GraphQL( new IndexGraphQLSchema(this).indexSchema, new ExecutorServiceExecutionStrategy(Executors.newCachedThreadPool( new ThreadFactoryBuilder().setNameFormat("GraphQLExecutor-" + graph.routerId + "-%d").build() )));
private void exampleExecutorServiceExecutionStrategy() { //::FigureH ExecutorService executorService = new ThreadPoolExecutor( 2, /* core pool size 2 thread */ 2, /* max pool size 2 thread */ 30, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new ThreadPoolExecutor.CallerRunsPolicy()); GraphQL graphQL = GraphQL.newGraphQL(StarWarsSchema.starWarsSchema) .queryExecutionStrategy(new ExecutorServiceExecutionStrategy(executorService)) .mutationExecutionStrategy(new AsyncSerialExecutionStrategy()) .build(); //::/FigureH }
void executionStrategies() { ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( 2, /* core pool size 2 thread */ 2, /* max pool size 2 thread */ 30, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new ThreadPoolExecutor.CallerRunsPolicy()); GraphQL graphQL = GraphQL.newGraphQL(StarWarsSchema.starWarsSchema) .queryExecutionStrategy(new ExecutorServiceExecutionStrategy(threadPoolExecutor)) .mutationExecutionStrategy(new AsyncExecutionStrategy()) .subscriptionExecutionStrategy(new AsyncExecutionStrategy()) .build(); }
private ExecutionStrategy createExecutionStrategy(Integer minimumThreadPoolSize, Integer maximumThreadPoolSize, Integer keepAliveTimeInSeconds, String threadNamePrefix) { return new ExecutorServiceExecutionStrategy(new ThreadPoolExecutor( minimumThreadPoolSize, maximumThreadPoolSize, keepAliveTimeInSeconds, TimeUnit.SECONDS, new SynchronousQueue<>(), new CustomizableThreadFactory(threadNamePrefix), new ThreadPoolExecutor.CallerRunsPolicy()) ); }