Skip to content

Commit

Permalink
feat: add config option to disable Quarkus thread pool usage (#923)
Browse files Browse the repository at this point in the history
  • Loading branch information
scrocquesel authored Sep 10, 2023
1 parent b19e022 commit 8ff71ca
Show file tree
Hide file tree
Showing 17 changed files with 1,118 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import java.util.Optional;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Function;
import java.util.function.Supplier;

Expand Down Expand Up @@ -292,9 +293,11 @@ private void createClientBuilders(
? asyncClientBuilderFunction.apply(asyncSdkAsyncHttpClientBuilder.get())
: null;

ScheduledExecutorService sharedExecutorService = executorBuildItem.getExecutorProxy();

if (syncClientBuilder != null) {
syncClientBuilder = recorder.configure(syncClientBuilder, awsConfigRuntime, sdkConfigRuntime,
sdkBuildConfig, executorBuildItem.getExecutorProxy(), configName());
sdkBuildConfig, sharedExecutorService, configName());
syntheticBeans.produce(SyntheticBeanBuildItem.configure(syncClientBuilderClass)
.setRuntimeInit()
.scope(ApplicationScoped.class)
Expand All @@ -304,7 +307,7 @@ private void createClientBuilders(
}
if (asyncClientBuilder != null) {
asyncClientBuilder = recorder.configure(asyncClientBuilder, awsConfigRuntime, sdkConfigRuntime,
sdkBuildConfig, executorBuildItem.getExecutorProxy(), configName());
sdkBuildConfig, sharedExecutorService, configName());
syntheticBeans.produce(SyntheticBeanBuildItem.configure(asyncClientBuilderClass)
.setRuntimeInit()
.scope(ApplicationScoped.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ public void initSdkClient(SdkClientBuilder builder, String extension, SdkConfig
config.endpointOverride().filter(URI::isAbsolute).ifPresent(builder::endpointOverride);

final ClientOverrideConfiguration.Builder overrides = ClientOverrideConfiguration.builder();
// use quarkus executor service
overrides.scheduledExecutorService(scheduledExecutorService);

if (config.advanced().useQuarkusScheduledExecutorService()) {
// use quarkus executor service
overrides.scheduledExecutorService(scheduledExecutorService);
}

config.apiCallTimeout().ifPresent(overrides::apiCallTimeout);
config.apiCallAttemptTimeout().ifPresent(overrides::apiCallAttemptTimeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.configuration.DurationConverter;
import io.smallrye.config.WithConverter;
import io.smallrye.config.WithDefault;

/**
* AWS SDK specific configurations
Expand Down Expand Up @@ -42,4 +43,22 @@ public interface SdkConfig {
*/
@WithConverter(DurationConverter.class)
Optional<Duration> apiCallAttemptTimeout();

/**
* sdk client advanced options
*/
Advanced advanced();

@ConfigGroup
public interface Advanced {

/**
* Whether the Quarkus thread pool should be used for scheduling tasks such as async retry attempts and timeout task.
* <p>
* When disabled, the default sdk behavior is to create a dedicated thread pool for each client, resulting in
* competition for CPU resources among these thread pools.
*/
@WithDefault("true")
boolean useQuarkusScheduledExecutorService();
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ h|Default

a|icon:lock[title=Fixed at build time] [[quarkus-amazon-dynamodb-enhanced_quarkus.dynamodbenhanced.client-extensions]]`link:#quarkus-amazon-dynamodb-enhanced_quarkus.dynamodbenhanced.client-extensions[quarkus.dynamodbenhanced.client-extensions]`


[.description]
--
List of extensions to load with the enhanced client.
Expand All @@ -30,6 +31,7 @@ endif::add-copy-button-to-env-var[]

a|icon:lock[title=Fixed at build time] [[quarkus-amazon-dynamodb-enhanced_quarkus.dynamodbenhanced.create-table-schemas]]`link:#quarkus-amazon-dynamodb-enhanced_quarkus.dynamodbenhanced.create-table-schemas[quarkus.dynamodbenhanced.create-table-schemas]`


[.description]
--
Whether a `TableSchema` should be created at start up for DynamoDb mappable entities annotated with `DynamoDbBean` or `DynamoDbImmutable`
Expand Down
Loading

0 comments on commit 8ff71ca

Please sign in to comment.