Last active
March 12, 2019 21:34
-
-
Save netstart/d666f617196c45c826cfae298664deaf to your computer and use it in GitHub Desktop.
Trick to build AsyncClient for AWS services in LocalStack
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
import java.util.function.Supplier; | |
import cloud.localstack.TestUtils; | |
import cloud.localstack.docker.LocalstackDocker; | |
public class TestAsyncUtils extends TestUtils { | |
public static AmazonDynamoDBAsync getClientDynamoDBAsync() { | |
return AmazonDynamoDBAsyncClientBuilder.standard() | |
.withEndpointConfiguration(createEndpointConfiguration(LocalstackDocker.INSTANCE::getEndpointDynamoDB)) | |
.withCredentials(getCredentialsProvider()) | |
.build(); | |
} | |
public static AmazonSQSAsync getClientSQSAsync() { | |
return getClientSQSAsync(null); | |
} | |
public static AmazonSQSAsync getClientSQSAsync(final ExecutorFactory executorFactory) { | |
return AmazonSQSAsyncClientBuilder.standard() | |
.withEndpointConfiguration(getEndpointConfigurationSQS()) | |
.withExecutorFactory(executorFactory) | |
.withCredentials(getCredentialsProvider()) | |
.build(); | |
} | |
protected static AwsClientBuilder.EndpointConfiguration createEndpointConfiguration(Supplier<String> supplier) { | |
return getEndpointConfiguration(supplier.get()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment