-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ability to specify different HTTP clients
- Loading branch information
Showing
25 changed files
with
309 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
22 changes: 22 additions & 0 deletions
22
...va/com/agorapulse/micronaut/amazon/awssdk/core/client/ApacheHttpClientBuilderFactory.java
This file contains 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,22 @@ | ||
package com.agorapulse.micronaut.amazon.awssdk.core.client; | ||
|
||
import io.micronaut.context.annotation.Bean; | ||
import io.micronaut.context.annotation.Factory; | ||
import io.micronaut.context.annotation.Requires; | ||
import jakarta.inject.Named; | ||
import jakarta.inject.Singleton; | ||
import software.amazon.awssdk.http.SdkHttpClient; | ||
import software.amazon.awssdk.http.apache.ApacheHttpClient; | ||
|
||
@Factory | ||
@Requires(classes = ApacheHttpClient.class) | ||
public class ApacheHttpClientBuilderFactory { | ||
|
||
@Bean | ||
@Singleton | ||
@Named("apache") | ||
public SdkHttpClient.Builder<ApacheHttpClient.Builder> awsCrtHttpClientBuilder() { | ||
return ApacheHttpClient.builder(); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...va/com/agorapulse/micronaut/amazon/awssdk/core/client/AwsCrtHttpClientBuilderFactory.java
This file contains 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,31 @@ | ||
package com.agorapulse.micronaut.amazon.awssdk.core.client; | ||
|
||
import io.micronaut.context.annotation.Bean; | ||
import io.micronaut.context.annotation.Factory; | ||
import io.micronaut.context.annotation.Requires; | ||
import jakarta.inject.Named; | ||
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; | ||
|
||
@Factory | ||
@Requires(classes = {AwsCrtHttpClient.class, AwsCrtAsyncHttpClient.class}) | ||
public class AwsCrtHttpClientBuilderFactory { | ||
|
||
@Bean | ||
@Singleton | ||
@Named("aws-crt") | ||
public SdkAsyncHttpClient.Builder<AwsCrtAsyncHttpClient.Builder> awsCrtHttpAsyncClientBuilder() { | ||
return AwsCrtAsyncHttpClient.builder(); | ||
} | ||
|
||
@Bean | ||
@Singleton | ||
@Named("aws-crt") | ||
public SdkHttpClient.Builder<AwsCrtHttpClient.Builder> awsCrtHttpClientBuilder() { | ||
return AwsCrtHttpClient.builder(); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...c/main/java/com/agorapulse/micronaut/amazon/awssdk/core/client/ClientBuilderProvider.java
This file contains 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 com.agorapulse.micronaut.amazon.awssdk.core.client; | ||
|
||
import software.amazon.awssdk.http.SdkHttpClient; | ||
import software.amazon.awssdk.http.async.SdkAsyncHttpClient; | ||
|
||
import java.util.Optional; | ||
|
||
public interface ClientBuilderProvider { | ||
|
||
String APACHE = "apache"; | ||
String AWS_CRT = "aws-crt"; | ||
String URL_CONNECTION = "url-connection"; | ||
String NETTY = "netty"; | ||
|
||
<B extends SdkHttpClient.Builder<B>> Optional<SdkHttpClient.Builder<B>> findHttpClientBuilder(String implementation); | ||
|
||
<B extends SdkAsyncHttpClient.Builder<B>> Optional<SdkAsyncHttpClient.Builder<B>> findAsyncHttpClientBuilder(String implementation); | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...java/com/agorapulse/micronaut/amazon/awssdk/core/client/DefaultClientBuilderProvider.java
This file contains 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,31 @@ | ||
package com.agorapulse.micronaut.amazon.awssdk.core.client; | ||
|
||
import io.micronaut.context.annotation.Bean; | ||
import software.amazon.awssdk.http.SdkHttpClient; | ||
import software.amazon.awssdk.http.async.SdkAsyncHttpClient; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
@Bean | ||
public class DefaultClientBuilderProvider implements ClientBuilderProvider { | ||
|
||
private final Map<String, SdkHttpClient.Builder<?>> httpClientBuilders; | ||
private final Map<String, SdkAsyncHttpClient.Builder<?>> httpAsyncClientBuilders; | ||
|
||
public DefaultClientBuilderProvider(Map<String, SdkHttpClient.Builder<?>> httpClientBuilders, Map<String, SdkAsyncHttpClient.Builder<?>> httpAsyncClientBuilders) { | ||
this.httpClientBuilders = httpClientBuilders; | ||
this.httpAsyncClientBuilders = httpAsyncClientBuilders; | ||
} | ||
|
||
@Override | ||
public <B extends SdkHttpClient.Builder<B>> Optional<SdkHttpClient.Builder<B>> findHttpClientBuilder(String implementation) { | ||
return Optional.ofNullable((SdkHttpClient.Builder<B>) httpClientBuilders.get(implementation)); | ||
} | ||
|
||
@Override | ||
public <B extends SdkAsyncHttpClient.Builder<B>> Optional<SdkAsyncHttpClient.Builder<B>> findAsyncHttpClientBuilder(String implementation) { | ||
return Optional.ofNullable((SdkAsyncHttpClient.Builder<B>) httpAsyncClientBuilders.get(implementation)); | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
...ava/com/agorapulse/micronaut/amazon/awssdk/core/client/NettyHttpClientBuilderFactory.java
This file contains 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,22 @@ | ||
package com.agorapulse.micronaut.amazon.awssdk.core.client; | ||
|
||
import io.micronaut.context.annotation.Bean; | ||
import io.micronaut.context.annotation.Factory; | ||
import io.micronaut.context.annotation.Requires; | ||
import jakarta.inject.Named; | ||
import jakarta.inject.Singleton; | ||
import software.amazon.awssdk.http.async.SdkAsyncHttpClient; | ||
import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient; | ||
|
||
@Factory | ||
@Requires(classes = NettyNioAsyncHttpClient.class) | ||
public class NettyHttpClientBuilderFactory { | ||
|
||
@Bean | ||
@Singleton | ||
@Named("netty") | ||
public SdkAsyncHttpClient.Builder<NettyNioAsyncHttpClient.Builder> nettyHttpAsyncClientBuilder() { | ||
return NettyNioAsyncHttpClient.builder(); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...agorapulse/micronaut/amazon/awssdk/core/client/UrlConnectionHttpClientBuilderFactory.java
This file contains 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,25 @@ | ||
package com.agorapulse.micronaut.amazon.awssdk.core.client; | ||
|
||
import io.micronaut.context.annotation.Bean; | ||
import io.micronaut.context.annotation.Factory; | ||
import io.micronaut.context.annotation.Requires; | ||
import jakarta.inject.Named; | ||
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.urlconnection.UrlConnectionHttpClient; | ||
|
||
@Factory | ||
@Requires(classes = UrlConnectionHttpClient.class) | ||
public class UrlConnectionHttpClientBuilderFactory { | ||
|
||
@Bean | ||
@Singleton | ||
@Named("url-connection") | ||
public SdkHttpClient.Builder<UrlConnectionHttpClient.Builder> awsCrtHttpClientBuilder() { | ||
return UrlConnectionHttpClient.builder(); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...roovy/com/agorapulse/micronaut/amazon/awssdk/core/client/ClientBuilderProviderSpec.groovy
This file contains 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,24 @@ | ||
package com.agorapulse.micronaut.amazon.awssdk.core.client | ||
|
||
import io.micronaut.test.extensions.spock.annotation.MicronautTest | ||
import jakarta.inject.Inject | ||
import spock.lang.Specification | ||
|
||
@MicronautTest | ||
class ClientBuilderProviderSpec extends Specification { | ||
|
||
@Inject ClientBuilderProvider provider | ||
|
||
void 'known providers found'() { | ||
expect: | ||
verifyAll(provider) { | ||
findHttpClientBuilder(ClientBuilderProvider.APACHE).present | ||
findHttpClientBuilder(ClientBuilderProvider.AWS_CRT).present | ||
findHttpClientBuilder(ClientBuilderProvider.URL_CONNECTION).present | ||
|
||
findAsyncHttpClientBuilder(ClientBuilderProvider.NETTY).present | ||
findAsyncHttpClientBuilder(ClientBuilderProvider.AWS_CRT).present | ||
} | ||
} | ||
|
||
} |
This file contains 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 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.