Skip to content

Commit

Permalink
feat(s3stream): make s3client configuration can be override (#1947)
Browse files Browse the repository at this point in the history
  • Loading branch information
warr99 committed Aug 26, 2024
1 parent 360f38d commit 77161bb
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.netty.buffer.CompositeByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.ssl.OpenSsl;

import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
Expand All @@ -33,6 +34,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider;
Expand All @@ -44,6 +46,7 @@
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.core.async.AsyncRequestBody;
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.http.HttpStatusCode;
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
Expand Down Expand Up @@ -417,11 +420,17 @@ protected S3AsyncClient newS3Client(String endpoint, String region, boolean forc
builder.httpClient(httpClient);
builder.serviceConfiguration(c -> c.pathStyleAccessEnabled(forcePathStyle));
builder.credentialsProvider(newCredentialsProviderChain(credentialsProviders));
builder.overrideConfiguration(b -> b.apiCallTimeout(Duration.ofMinutes(2))
.apiCallAttemptTimeout(Duration.ofSeconds(60)));
builder.overrideConfiguration(clientOverrideConfiguration());
return builder.build();
}

protected ClientOverrideConfiguration clientOverrideConfiguration() {
return ClientOverrideConfiguration.builder()
.apiCallTimeout(Duration.ofMinutes(2))
.apiCallAttemptTimeout(Duration.ofSeconds(60))
.build();
}

private AwsCredentialsProvider newCredentialsProviderChain(List<AwsCredentialsProvider> credentialsProviders) {
List<AwsCredentialsProvider> providers = new ArrayList<>(credentialsProviders);
// Add default providers to the end of the chain
Expand Down

0 comments on commit 77161bb

Please sign in to comment.