Skip to content

Commit 77161bb

Browse files
authored
feat(s3stream): make s3client configuration can be override (AutoMQ#1947)
1 parent 360f38d commit 77161bb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

s3stream/src/main/java/com/automq/stream/s3/operator/AwsObjectStorage.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.netty.buffer.CompositeByteBuf;
2121
import io.netty.buffer.Unpooled;
2222
import io.netty.handler.ssl.OpenSsl;
23+
2324
import java.net.URI;
2425
import java.nio.charset.StandardCharsets;
2526
import java.time.Duration;
@@ -33,6 +34,7 @@
3334
import java.util.concurrent.CompletableFuture;
3435
import java.util.function.Supplier;
3536
import java.util.stream.Collectors;
37+
3638
import org.apache.commons.lang3.StringUtils;
3739
import org.apache.commons.lang3.tuple.Pair;
3840
import software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider;
@@ -44,6 +46,7 @@
4446
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
4547
import software.amazon.awssdk.core.async.AsyncRequestBody;
4648
import software.amazon.awssdk.core.async.AsyncResponseTransformer;
49+
import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
4750
import software.amazon.awssdk.core.exception.SdkClientException;
4851
import software.amazon.awssdk.http.HttpStatusCode;
4952
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
@@ -417,11 +420,17 @@ protected S3AsyncClient newS3Client(String endpoint, String region, boolean forc
417420
builder.httpClient(httpClient);
418421
builder.serviceConfiguration(c -> c.pathStyleAccessEnabled(forcePathStyle));
419422
builder.credentialsProvider(newCredentialsProviderChain(credentialsProviders));
420-
builder.overrideConfiguration(b -> b.apiCallTimeout(Duration.ofMinutes(2))
421-
.apiCallAttemptTimeout(Duration.ofSeconds(60)));
423+
builder.overrideConfiguration(clientOverrideConfiguration());
422424
return builder.build();
423425
}
424426

427+
protected ClientOverrideConfiguration clientOverrideConfiguration() {
428+
return ClientOverrideConfiguration.builder()
429+
.apiCallTimeout(Duration.ofMinutes(2))
430+
.apiCallAttemptTimeout(Duration.ofSeconds(60))
431+
.build();
432+
}
433+
425434
private AwsCredentialsProvider newCredentialsProviderChain(List<AwsCredentialsProvider> credentialsProviders) {
426435
List<AwsCredentialsProvider> providers = new ArrayList<>(credentialsProviders);
427436
// Add default providers to the end of the chain

0 commit comments

Comments
 (0)