Skip to content

Commit

Permalink
feat: introduce multiple client configuration (#1304)
Browse files Browse the repository at this point in the history
* refactor: replace client bean producers with synthetic beans

* feat: introduce multiple clients
  • Loading branch information
scrocquesel authored Sep 29, 2024
1 parent b9a7417 commit 676d432
Show file tree
Hide file tree
Showing 172 changed files with 45,213 additions and 11,946 deletions.
17 changes: 16 additions & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,20 @@
</dependency>
</dependencies>
</dependencyManagement>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.version}</version>
</plugin>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-config-doc-maven-plugin</artifactId>
<version>${quarkus.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
import org.jboss.jandex.DotName;

import io.quarkus.amazon.cloudwatch.runtime.CloudWatchBuildTimeConfig;
import io.quarkus.amazon.cloudwatch.runtime.CloudWatchClientProducer;
import io.quarkus.amazon.cloudwatch.runtime.CloudWatchRecorder;
import io.quarkus.amazon.common.deployment.*;
import io.quarkus.amazon.common.deployment.spi.EventLoopGroupBuildItem;
import io.quarkus.amazon.common.runtime.*;
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
Expand Down Expand Up @@ -57,11 +55,6 @@ protected String builtinInterceptorsPath() {
return "software/amazon/awssdk/services/cloudwatch/execution.interceptors";
}

@BuildStep
AdditionalBeanBuildItem producer() {
return AdditionalBeanBuildItem.unremovableOf(CloudWatchClientProducer.class);
}

@BuildStep
void setup(
BuildProducer<ExtensionSslNativeSupportBuildItem> extensionSslNativeSupport,
Expand All @@ -72,10 +65,18 @@ void setup(
}

@BuildStep
void discover(BeanRegistrationPhaseBuildItem beanRegistrationPhase,
void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase,
BuildProducer<RequireAmazonClientInjectionBuildItem> requireClientInjectionProducer) {

discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer);
}

@BuildStep
void discover(
List<RequireAmazonClientInjectionBuildItem> amazonClientInjectionPoints,
BuildProducer<RequireAmazonClientBuildItem> requireClientProducer) {

discoverClient(beanRegistrationPhase, requireClientProducer);
discoverClient(amazonClientInjectionPoints, requireClientProducer);
}

@BuildStep
Expand All @@ -86,15 +87,15 @@ void discoverTelemetry(BuildProducer<RequireAmazonTelemetryBuildItem> telemetryP

@BuildStep
void setupClient(List<RequireAmazonClientBuildItem> clientRequirements,
BuildProducer<AmazonClientBuildItem> clientProducer) {
BuildProducer<RequireAmazonClientTransportBuilderBuildItem> clientProducer) {

setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(),
buildTimeConfig.asyncClient());
}

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupApacheSyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWatchRecorder recorder,
void setupApacheSyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients, CloudWatchRecorder recorder,
AmazonClientApacheTransportRecorder transportRecorder,
BuildProducer<AmazonClientSyncTransportBuildItem> syncTransports) {

Expand All @@ -107,7 +108,7 @@ void setupApacheSyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWa

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupAwsCrtSyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWatchRecorder recorder,
void setupAwsCrtSyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients, CloudWatchRecorder recorder,
AmazonClientAwsCrtTransportRecorder transportRecorder,
BuildProducer<AmazonClientSyncTransportBuildItem> syncTransports) {

Expand All @@ -120,7 +121,8 @@ void setupAwsCrtSyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWa

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupUrlConnectionSyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWatchRecorder recorder,
void setupUrlConnectionSyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients,
CloudWatchRecorder recorder,
AmazonClientUrlConnectionTransportRecorder transportRecorder,
BuildProducer<AmazonClientSyncTransportBuildItem> syncTransports) {

Expand All @@ -133,7 +135,7 @@ void setupUrlConnectionSyncTransport(List<AmazonClientBuildItem> amazonClients,

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupNettyAsyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWatchRecorder recorder,
void setupNettyAsyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients, CloudWatchRecorder recorder,
AmazonClientNettyTransportRecorder transportRecorder,
BuildProducer<AmazonClientAsyncTransportBuildItem> asyncTransports,
EventLoopGroupBuildItem eventLoopSupplier) {
Expand All @@ -147,7 +149,8 @@ void setupNettyAsyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWa

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupAwsCrtAsyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWatchRecorder recorder,
void setupAwsCrtAsyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients,
CloudWatchRecorder recorder,
AmazonClientAwsCrtTransportRecorder transportRecorder,
BuildProducer<AmazonClientAsyncTransportBuildItem> asyncTransports) {

Expand All @@ -163,6 +166,7 @@ void setupAwsCrtAsyncTransport(List<AmazonClientBuildItem> amazonClients, CloudW
void createClientBuilders(CloudWatchRecorder recorder,
AmazonClientCommonRecorder commonRecorder,
AmazonClientOpenTelemetryRecorder otelRecorder,
List<RequireAmazonClientInjectionBuildItem> amazonClientInjections,
List<RequireAmazonTelemetryBuildItem> amazonRequireTelemtryClients,
List<AmazonClientSyncTransportBuildItem> syncTransports,
List<AmazonClientAsyncTransportBuildItem> asyncTransports,
Expand All @@ -177,6 +181,7 @@ void createClientBuilders(CloudWatchRecorder recorder,
commonRecorder,
otelRecorder,
buildTimeConfig,
amazonClientInjections,
amazonRequireTelemtryClients,
syncTransports,
asyncTransports,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
package io.quarkus.amazon.cloudwatch.runtime;

import io.quarkus.amazon.common.runtime.AsyncHttpClientConfig;
import io.quarkus.amazon.common.runtime.AwsConfig;
import io.quarkus.amazon.common.runtime.SdkConfig;
import io.quarkus.amazon.common.runtime.HasAmazonClientRuntimeConfig;
import io.quarkus.amazon.common.runtime.SyncHttpClientConfig;
import io.quarkus.runtime.annotations.ConfigDocSection;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithParentName;

@ConfigMapping(prefix = "quarkus.cloudwatch")
@ConfigRoot(phase = ConfigPhase.RUN_TIME)
public interface CloudWatchConfig {
/**
* AWS SDK client configurations
*/
@WithParentName
@ConfigDocSection
SdkConfig sdk();

/**
* AWS services configurations
*/
@ConfigDocSection
AwsConfig aws();

public interface CloudWatchConfig extends HasAmazonClientRuntimeConfig {
/**
* Sync HTTP transport configurations
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ public CloudWatchRecorder(CloudWatchConfig config) {
}

@Override
public RuntimeValue<AwsConfig> getAwsConfig() {
return new RuntimeValue<>(config.aws());
}

@Override
public RuntimeValue<SdkConfig> getSdkConfig() {
return new RuntimeValue<>(config.sdk());
public RuntimeValue<HasAmazonClientRuntimeConfig> getAmazonClientsConfig() {
return new RuntimeValue<>(config);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
import org.jboss.jandex.DotName;

import io.quarkus.amazon.cloudwatch.runtime.CloudWatchLogsBuildTimeConfig;
import io.quarkus.amazon.cloudwatch.runtime.CloudWatchLogsClientProducer;
import io.quarkus.amazon.cloudwatch.runtime.CloudWatchLogsRecorder;
import io.quarkus.amazon.common.deployment.*;
import io.quarkus.amazon.common.deployment.spi.EventLoopGroupBuildItem;
import io.quarkus.amazon.common.runtime.*;
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
Expand Down Expand Up @@ -57,11 +55,6 @@ protected String builtinInterceptorsPath() {
return "software/amazon/awssdk/services/cloudwatchlogs/execution.interceptors";
}

@BuildStep
AdditionalBeanBuildItem producer() {
return AdditionalBeanBuildItem.unremovableOf(CloudWatchLogsClientProducer.class);
}

@BuildStep
void setup(
BuildProducer<ExtensionSslNativeSupportBuildItem> extensionSslNativeSupport,
Expand All @@ -72,10 +65,18 @@ void setup(
}

@BuildStep
void discover(BeanRegistrationPhaseBuildItem beanRegistrationPhase,
void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase,
BuildProducer<RequireAmazonClientInjectionBuildItem> requireClientInjectionProducer) {

discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer);
}

@BuildStep
void discover(
List<RequireAmazonClientInjectionBuildItem> amazonClientInjectionPoints,
BuildProducer<RequireAmazonClientBuildItem> requireClientProducer) {

discoverClient(beanRegistrationPhase, requireClientProducer);
discoverClient(amazonClientInjectionPoints, requireClientProducer);
}

@BuildStep
Expand All @@ -86,15 +87,16 @@ void discoverTelemetry(BuildProducer<RequireAmazonTelemetryBuildItem> telemetryP

@BuildStep
void setupClient(List<RequireAmazonClientBuildItem> clientRequirements,
BuildProducer<AmazonClientBuildItem> clientProducer) {
BuildProducer<RequireAmazonClientTransportBuilderBuildItem> clientProducer) {

setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(),
buildTimeConfig.asyncClient());
}

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupApacheSyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWatchLogsRecorder recorder,
void setupApacheSyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients,
CloudWatchLogsRecorder recorder,
AmazonClientApacheTransportRecorder transportRecorder,
BuildProducer<AmazonClientSyncTransportBuildItem> syncTransports) {

Expand All @@ -107,7 +109,8 @@ void setupApacheSyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWa

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupAwsCrtSyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWatchLogsRecorder recorder,
void setupAwsCrtSyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients,
CloudWatchLogsRecorder recorder,
AmazonClientAwsCrtTransportRecorder transportRecorder,
BuildProducer<AmazonClientSyncTransportBuildItem> syncTransports) {

Expand All @@ -120,7 +123,8 @@ void setupAwsCrtSyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWa

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupUrlConnectionSyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWatchLogsRecorder recorder,
void setupUrlConnectionSyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients,
CloudWatchLogsRecorder recorder,
AmazonClientUrlConnectionTransportRecorder transportRecorder,
BuildProducer<AmazonClientSyncTransportBuildItem> syncTransports) {

Expand All @@ -133,7 +137,8 @@ void setupUrlConnectionSyncTransport(List<AmazonClientBuildItem> amazonClients,

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupNettyAsyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWatchLogsRecorder recorder,
void setupNettyAsyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients,
CloudWatchLogsRecorder recorder,
AmazonClientNettyTransportRecorder transportRecorder,
BuildProducer<AmazonClientAsyncTransportBuildItem> asyncTransports,
EventLoopGroupBuildItem eventLoopSupplier) {
Expand All @@ -147,7 +152,8 @@ void setupNettyAsyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWa

@BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class)
@Record(ExecutionTime.RUNTIME_INIT)
void setupAwsCrtAsyncTransport(List<AmazonClientBuildItem> amazonClients, CloudWatchLogsRecorder recorder,
void setupAwsCrtAsyncTransport(List<RequireAmazonClientTransportBuilderBuildItem> amazonClients,
CloudWatchLogsRecorder recorder,
AmazonClientAwsCrtTransportRecorder transportRecorder,
BuildProducer<AmazonClientAsyncTransportBuildItem> asyncTransports) {

Expand All @@ -163,6 +169,7 @@ void setupAwsCrtAsyncTransport(List<AmazonClientBuildItem> amazonClients, CloudW
void createClientBuilders(CloudWatchLogsRecorder recorder,
AmazonClientCommonRecorder commonRecorder,
AmazonClientOpenTelemetryRecorder otelRecorder,
List<RequireAmazonClientInjectionBuildItem> amazonClientInjections,
List<RequireAmazonTelemetryBuildItem> amazonRequireTelemtryClients,
List<AmazonClientSyncTransportBuildItem> syncTransports,
List<AmazonClientAsyncTransportBuildItem> asyncTransports,
Expand All @@ -177,6 +184,7 @@ void createClientBuilders(CloudWatchLogsRecorder recorder,
commonRecorder,
otelRecorder,
buildTimeConfig,
amazonClientInjections,
amazonRequireTelemtryClients,
syncTransports,
asyncTransports,
Expand Down
Loading

0 comments on commit 676d432

Please sign in to comment.