-
Notifications
You must be signed in to change notification settings - Fork 85
Add support for AWS CRT Client #2434
New issue
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
Open
driverpt
wants to merge
10
commits into
micronaut-projects:4.12.x
Choose a base branch
from
driverpt:add-aws-crt-client-support
base: 4.12.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+261
−1
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9fcb4e1
Add support for AWS CRT Client
driverpt 02c825e
Make checkstyle happy :)
driverpt afc4d4b
Add Docs
driverpt 61f6ed9
Merge branch '4.12.x' into pr/2434
sdelamo 1a4ca29
link documentation file from the table of contents
sdelamo ff98bcc
link to AWS CRT docs
sdelamo a4972b7
fix copy paste java doc mistake
sdelamo de1d43b
create builders as beans
sdelamo b15be75
add missing beans
sdelamo 976900f
remove clients instantatiation without property
sdelamo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/client/crt/AwsCrtClientConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* | ||
| * Copyright 2017-2020 original authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.micronaut.aws.sdk.v2.client.crt; | ||
|
|
||
| import io.micronaut.aws.AWSConfiguration; | ||
| import io.micronaut.context.annotation.BootstrapContextCompatible; | ||
| import io.micronaut.context.annotation.ConfigurationBuilder; | ||
| import io.micronaut.context.annotation.ConfigurationProperties; | ||
| import io.micronaut.core.annotation.NonNull; | ||
| import software.amazon.awssdk.http.crt.AwsCrtAsyncHttpClient; | ||
| import software.amazon.awssdk.http.crt.AwsCrtHttpClient; | ||
| import software.amazon.awssdk.http.crt.ProxyConfiguration; | ||
|
|
||
| /** | ||
| * Configuration properties for the CRT HTTP client. | ||
| * | ||
| * @author Luis Duarte | ||
| * @since 4.12.x | ||
| */ | ||
| @ConfigurationProperties(AwsCrtClientConfiguration.PREFIX) | ||
| @BootstrapContextCompatible | ||
| public class AwsCrtClientConfiguration extends AWSConfiguration { | ||
|
|
||
| public static final String PREFIX = "crt-client"; | ||
|
|
||
| @ConfigurationBuilder(prefixes = {""}, excludes = {"proxyConfiguration", "buildWithDefaults", "applyMutation"}) | ||
| private AwsCrtHttpClient.Builder sync = AwsCrtHttpClient.builder(); | ||
|
|
||
| @ConfigurationBuilder(prefixes = {""}, excludes = {"proxyConfiguration", "buildWithDefaults", "applyMutation"}) | ||
| private AwsCrtAsyncHttpClient.Builder async = AwsCrtAsyncHttpClient.builder(); | ||
|
|
||
| @ConfigurationBuilder(configurationPrefix = "proxy", prefixes = {""}, excludes = {"applyMutation", "copy"}) | ||
| private ProxyConfiguration.Builder proxy = ProxyConfiguration.builder(); | ||
|
|
||
| /** | ||
| * | ||
| * @return AWS CRT HTTP Client builder | ||
| */ | ||
| @NonNull | ||
| public AwsCrtHttpClient.Builder getSync() { | ||
| return sync; | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| * @return AWS CRT Async HTTP Client builder | ||
| */ | ||
| @NonNull | ||
| public AwsCrtAsyncHttpClient.Builder getAsync() { | ||
| return async; | ||
| } | ||
|
|
||
| /** | ||
| * @return The builder for {@link ProxyConfiguration} | ||
| */ | ||
| public ProxyConfiguration.Builder getProxy() { | ||
| return proxy; | ||
| } | ||
| } | ||
110 changes: 110 additions & 0 deletions
110
aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/client/crt/AwsCrtClientFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| /* | ||
| * Copyright 2017-2025 original authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.micronaut.aws.sdk.v2.client.crt; | ||
|
|
||
| import io.micronaut.context.annotation.Bean; | ||
| import io.micronaut.context.annotation.BootstrapContextCompatible; | ||
| import io.micronaut.context.annotation.Factory; | ||
| import io.micronaut.context.annotation.Prototype; | ||
| import io.micronaut.context.annotation.Requires; | ||
| import io.micronaut.core.annotation.Internal; | ||
| import jakarta.inject.Singleton; | ||
| import software.amazon.awssdk.http.SdkHttpClient; | ||
| import software.amazon.awssdk.http.async.SdkAsyncHttpClient; | ||
| import software.amazon.awssdk.http.crt.AwsCrtAsyncHttpClient; | ||
| import software.amazon.awssdk.http.crt.AwsCrtHttpClient; | ||
| import software.amazon.awssdk.http.crt.ProxyConfiguration; | ||
|
|
||
| import static io.micronaut.aws.sdk.v2.client.netty.NettyClientFactory.ASYNC_SERVICE_IMPL; | ||
| import static io.micronaut.aws.sdk.v2.client.urlConnection.UrlConnectionClientFactory.HTTP_SERVICE_IMPL; | ||
|
|
||
| /** | ||
| * @since 4.12.0 | ||
| */ | ||
| @Factory | ||
| @BootstrapContextCompatible | ||
sdelamo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @Internal | ||
| class AwsCrtClientFactory { | ||
| public static final String AWS_CRT_SDK_HTTP_SERVICE = "software.amazon.awssdk.http.crt.AwsCrtSdkHttpService"; | ||
|
|
||
| @Prototype | ||
| ProxyConfiguration.Builder createProxyBuilder(AwsCrtClientConfiguration configuration) { | ||
| return ProxyConfiguration.builder(); | ||
| } | ||
|
|
||
| @Prototype | ||
| ProxyConfiguration createProxyConfiguration(ProxyConfiguration.Builder builder) { | ||
| return builder.build(); | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| * @param proxyConfiguration Proxy Configuration | ||
| * @param awsCrtClientConfiguration AWS CRT Client Configuration | ||
| * @return AWS CRT HTTP Client Builder | ||
| */ | ||
| @Prototype | ||
| AwsCrtHttpClient.Builder createAwsCrtHttpClientBuilder(ProxyConfiguration proxyConfiguration, | ||
| AwsCrtClientConfiguration awsCrtClientConfiguration) { | ||
| AwsCrtHttpClient.Builder builder = awsCrtClientConfiguration.getSync(); | ||
| if (isProxyConfigured(proxyConfiguration)) { | ||
| builder.proxyConfiguration(proxyConfiguration); | ||
| } | ||
| return builder; | ||
| } | ||
|
|
||
| /** | ||
| * @param awsCrtHttpClientBuilder AWS CRT HTTP Client Builder | ||
| * @return an instance of {@link SdkAsyncHttpClient} | ||
| */ | ||
| @Bean(preDestroy = "close") | ||
| @Singleton | ||
| @Requires(property = HTTP_SERVICE_IMPL, value = AWS_CRT_SDK_HTTP_SERVICE) | ||
| public SdkHttpClient systemPropertySdkHttpClient(AwsCrtHttpClient.Builder awsCrtHttpClientBuilder) { | ||
| return awsCrtHttpClientBuilder.build(); | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| * @param proxyConfiguration Proxy Configuration | ||
| * @param awsCrtClientConfiguration AWS CRT Client Configuration | ||
| * @return AWS CRT Async HTTP Client Builder | ||
| */ | ||
| @Prototype | ||
| AwsCrtAsyncHttpClient.Builder createAwsCrtAsyncHttpClientBuilder(ProxyConfiguration proxyConfiguration, | ||
| AwsCrtClientConfiguration awsCrtClientConfiguration) { | ||
| AwsCrtAsyncHttpClient.Builder builder = awsCrtClientConfiguration.getAsync(); | ||
| if (isProxyConfigured(proxyConfiguration)) { | ||
| builder.proxyConfiguration(proxyConfiguration); | ||
| } | ||
| return builder; | ||
| } | ||
|
|
||
| /** | ||
| * @param awsCrtAsyncHttpClientBuilder AWS CRT Async HTTP Client Builder | ||
| * @return an instance of {@link SdkAsyncHttpClient} | ||
| */ | ||
| @Bean(preDestroy = "close") | ||
| @Singleton | ||
| @Requires(property = ASYNC_SERVICE_IMPL, value = AWS_CRT_SDK_HTTP_SERVICE) | ||
| public SdkAsyncHttpClient systemPropertySdkAsyncHttpClient(AwsCrtAsyncHttpClient.Builder awsCrtAsyncHttpClientBuilder) { | ||
| return awsCrtAsyncHttpClientBuilder.build(); | ||
| } | ||
|
|
||
| private static boolean isProxyConfigured(ProxyConfiguration proxyConfiguration) { | ||
| return proxyConfiguration.host() != null; | ||
| } | ||
| } | ||
28 changes: 28 additions & 0 deletions
28
aws-sdk-v2/src/main/java/io/micronaut/aws/sdk/v2/client/crt/package-info.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * Copyright 2017-2020 original authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| /** | ||
| * AWS CRT client configuration and factory. | ||
| * | ||
| * @author Luis Duarte | ||
| * @since 4.12.x | ||
| */ | ||
| @Requires(classes = { AwsCrtHttpClient.class }) | ||
| @Configuration | ||
| package io.micronaut.aws.sdk.v2.client.crt; | ||
|
|
||
| import io.micronaut.context.annotation.Configuration; | ||
| import io.micronaut.context.annotation.Requires; | ||
| import software.amazon.awssdk.http.crt.AwsCrtHttpClient; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...2/src/test/groovy/io/micronaut/aws/sdk/v2/client/crt/AwsCrtClientConfigurationSpec.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package io.micronaut.aws.sdk.v2.client.crt | ||
|
|
||
| import io.micronaut.context.ApplicationContext | ||
| import io.micronaut.context.annotation.BootstrapContextCompatible | ||
| import spock.lang.Specification | ||
|
|
||
| class AwsCrtClientConfigurationSpec extends Specification { | ||
|
|
||
| void 'AwsCrtClientConfiguration is annotated with BootstrapContextCompatible'() { | ||
| given: | ||
| ApplicationContext context = ApplicationContext.run() | ||
|
|
||
| expect: | ||
| context.getBeanDefinition(AwsCrtClientConfiguration).getAnnotationNameByStereotype(BootstrapContextCompatible).isPresent() | ||
|
|
||
| cleanup: | ||
| context.close() | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
aws-sdk-v2/src/test/groovy/io/micronaut/aws/sdk/v2/client/crt/AwsCrtClientFactorySpec.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package io.micronaut.aws.sdk.v2.client.crt | ||
|
|
||
| import io.micronaut.context.ApplicationContext | ||
| import io.micronaut.context.annotation.BootstrapContextCompatible | ||
| import spock.lang.Specification | ||
|
|
||
| class AwsCrtClientFactorySpec extends Specification { | ||
|
|
||
| void 'AwsCrtClientFactory is annotated with BootstrapContextCompatible'() { | ||
| given: | ||
| ApplicationContext context = ApplicationContext.run() | ||
|
|
||
| expect: | ||
| context.getBeanDefinition(AwsCrtClientFactory).getAnnotationNameByStereotype(BootstrapContextCompatible).isPresent() | ||
|
|
||
| cleanup: | ||
| context.close() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| The https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/http-configuration-crt.html[AWS CRT Client] can be configured with the following options: | ||
|
|
||
| include::{includedir}configurationProperties/software.amazon.awssdk.http.crt.AwsCrtAsyncHttpClient$Builder.adoc[] | ||
|
|
||
| include::{includedir}configurationProperties/software.amazon.awssdk.http.crt.ProxyConfiguration$Builder.adoc[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.