Skip to content

Commit bc2fa0a

Browse files
committed
feat: s3 transfer manager client
1 parent b2e40c4 commit bc2fa0a

File tree

10 files changed

+108
-1
lines changed

10 files changed

+108
-1
lines changed

aws-runtime/aws-http/api/aws-http.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public final class aws/sdk/kotlin/runtime/http/interceptors/IgnoreCompositeFlexi
171171
public final class aws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetric : java/lang/Enum, aws/smithy/kotlin/runtime/businessmetrics/BusinessMetric {
172172
public static final field DDB_MAPPER Laws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetric;
173173
public static final field S3_EXPRESS_BUCKET Laws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetric;
174+
public static final field S3_TRANSFER Laws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetric;
174175
public static fun getEntries ()Lkotlin/enums/EnumEntries;
175176
public fun getIdentifier ()Ljava/lang/String;
176177
public fun toString ()Ljava/lang/String;

aws-runtime/aws-http/common/src/aws/sdk/kotlin/runtime/http/interceptors/businessmetrics/AwsBusinessMetricsUtils.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ internal fun formatMetrics(metrics: MutableSet<BusinessMetric>, logger: Logger):
6262
public enum class AwsBusinessMetric(public override val identifier: String) : BusinessMetric {
6363
S3_EXPRESS_BUCKET("J"),
6464
DDB_MAPPER("d"),
65+
S3_TRANSFER("G"),
6566
;
6667

6768
@InternalApi

hll/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ val hllPreviewVersion = if (sdkVersion.contains("-SNAPSHOT")) { // e.g. 1.3.29-b
4545

4646
subprojects {
4747
group = "aws.sdk.kotlin"
48-
version = hllPreviewVersion
48+
version = if (name == "s3-transfer-manager") sdkVersion else hllPreviewVersion
4949
// TODO Use configurePublishing when migrating to Sonatype Publisher API / JReleaser
5050
configurePublishing("aws-sdk-kotlin")
5151
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public final class aws/sdk/kotlin/hll/s3transfermanager/S3TransferManager {
2+
public fun <init> ()V
3+
}
4+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
description = "S3 Transfer Manager for the AWS SDK for Kotlin"
7+
extra["displayName"] = "AWS :: SDK :: Kotlin :: HLL :: S3TransferManager"
8+
extra["moduleName"] = "aws.sdk.kotlin.hll.s3transfermanager"
9+
10+
kotlin {
11+
sourceSets {
12+
commonMain {
13+
dependencies {
14+
implementation(project(":aws-runtime:aws-http"))
15+
implementation(project(":services:s3"))
16+
}
17+
}
18+
}
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package aws.sdk.kotlin.hll.s3transfermanager
2+
3+
import aws.sdk.kotlin.runtime.http.interceptors.businessmetrics.AwsBusinessMetric
4+
import aws.smithy.kotlin.runtime.businessmetrics.emitBusinessMetric
5+
import aws.smithy.kotlin.runtime.client.RequestInterceptorContext
6+
import aws.smithy.kotlin.runtime.http.interceptors.HttpInterceptor
7+
8+
/**
9+
* An interceptor that emits the S3 Transfer Manager business metric
10+
*/
11+
internal object BusinessMetricInterceptor : HttpInterceptor {
12+
override suspend fun modifyBeforeSerialization(context: RequestInterceptorContext<Any>): Any {
13+
context.executionContext.emitBusinessMetric(AwsBusinessMetric.S3_TRANSFER)
14+
return context.request
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package aws.sdk.kotlin.hll.s3transfermanager
2+
3+
/**
4+
* TODO
5+
*/
6+
public sealed interface MultiPartDownloadType
7+
8+
/**
9+
* TODO
10+
*/
11+
public object Range : MultiPartDownloadType
12+
13+
/**
14+
* TODO
15+
*/
16+
public object Part : MultiPartDownloadType
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package aws.sdk.kotlin.hll.s3transfermanager
7+
8+
import aws.sdk.kotlin.services.s3.S3Client
9+
import aws.sdk.kotlin.services.s3.withConfig
10+
11+
/**
12+
* High level utility for managing transfers to Amazon S3.
13+
*/
14+
public class S3TransferManager private constructor(
15+
public val client: S3Client,
16+
public val partSize: Long?,
17+
public val multipartUploadThreshold: Long?,
18+
public val multipartDownloadType: MultiPartDownloadType?,
19+
public val interceptors: MutableList<TransferInterceptor>?,
20+
) {
21+
public companion object {
22+
public operator fun invoke(block: Builder.() -> Unit): S3TransferManager =
23+
Builder().apply(block).build()
24+
}
25+
26+
public class Builder {
27+
public var client: S3Client? = null
28+
public var partSize: Long? = 8_000_000L
29+
public var multipartUploadThreshold: Long? = 16_000_000L
30+
public var multipartDownloadType: MultiPartDownloadType? = Part
31+
public var interceptors: MutableList<TransferInterceptor>? = mutableListOf()
32+
33+
internal fun build(): S3TransferManager =
34+
S3TransferManager(
35+
client = client?.withConfig { interceptors += BusinessMetricInterceptor } ?: error("client must be set"),
36+
partSize = partSize,
37+
multipartUploadThreshold = multipartUploadThreshold,
38+
multipartDownloadType = multipartDownloadType,
39+
interceptors = interceptors
40+
)
41+
}
42+
43+
public fun x(): String = "" // TODO
44+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package aws.sdk.kotlin.hll.s3transfermanager
2+
3+
public class TransferInterceptor {
4+
// TODO
5+
}

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ include(":aws-runtime:aws-http")
5757
include(":hll")
5858
include(":hll:hll-codegen")
5959
include(":hll:hll-mapping-core")
60+
include(":hll:s3-transfer-manager")
6061
include(":services")
6162
include(":tests")
6263
include(":tests:codegen")

0 commit comments

Comments
 (0)