Skip to content

Commit 656c95a

Browse files
committed
refactor: re-paper crt engine to smithy kotlin and incorporate into common test suite
1 parent 367a89b commit 656c95a

File tree

29 files changed

+80
-188
lines changed

29 files changed

+80
-188
lines changed

builder.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
"test_steps": [
2222
"{gradlew} test allTests"
2323
],
24+
"upstream": [
25+
{
26+
"name": "aws-crt-kotlin"
27+
}
28+
],
2429
"downstream": [
2530
{ "name": "aws-sdk-kotlin" }
2631
]

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ kotlinLoggingVersion=2.0.3
3939

4040
# logging - JVM
4141
slf4jVersion=1.7.30
42+
43+
# crt
44+
crtKotlinVersion=0.5.4-SNAPSHOT

runtime/crt-util/build.gradle.kts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,31 @@ buildscript {
1717
apply(plugin = "kotlinx-atomicfu")
1818

1919
description = "Utilities for working with AWS CRT Kotlin"
20-
extra["displayName"] = "AWS :: SDK :: Kotlin :: CRT :: Util"
21-
extra["moduleName"] = "aws.sdk.kotlin.runtime.crt"
20+
extra["displayName"] = "Smithy :: Kotlin :: CRT :: Util"
21+
extra["moduleName"] = "aws.smithy.kotlin.runtime.crt"
2222

2323
val atomicFuVersion: String by project
2424
val coroutinesVersion: String by project
2525
val crtKotlinVersion: String by project
26-
val smithyKotlinVersion: String by project
2726

2827
kotlin {
2928
sourceSets {
3029
commonMain {
3130
dependencies {
32-
api(project(":aws-runtime:aws-core"))
31+
api(project(":runtime:runtime-core"))
3332
api("aws.sdk.kotlin.crt:aws-crt-kotlin:$crtKotlinVersion")
34-
api("aws.smithy.kotlin:http:$smithyKotlinVersion")
33+
api(project(":runtime:protocol:http"))
3534
implementation("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion")
3635
}
3736
}
3837
commonTest {
3938
dependencies {
40-
implementation(project(":aws-runtime:testing"))
4139
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
4240
}
4341
}
4442

4543
all {
4644
languageSettings.optIn("aws.smithy.kotlin.runtime.util.InternalApi")
47-
languageSettings.optIn("aws.sdk.kotlin.runtime.InternalSdkApi")
4845
}
4946
}
5047
}

runtime/crt-util/common/src/aws/sdk/kotlin/runtime/crt/Http.kt renamed to runtime/crt-util/common/src/aws/smithy/kotlin/runtime/crt/Http.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
* SPDX-License-Identifier: Apache-2.0.
44
*/
55

6-
package aws.sdk.kotlin.runtime.crt
6+
package aws.smithy.kotlin.runtime.crt
77

88
import aws.sdk.kotlin.crt.http.HttpRequestBodyStream
9-
import aws.sdk.kotlin.runtime.InternalSdkApi
109
import aws.smithy.kotlin.runtime.http.*
1110
import aws.smithy.kotlin.runtime.http.request.HttpRequest
1211
import aws.smithy.kotlin.runtime.http.request.HttpRequestBuilder
1312
import aws.smithy.kotlin.runtime.http.util.splitAsQueryParameters
13+
import aws.smithy.kotlin.runtime.util.InternalApi
1414
import kotlin.coroutines.coroutineContext
1515
import aws.sdk.kotlin.crt.http.Headers as HeadersCrt
1616
import aws.sdk.kotlin.crt.http.HttpRequest as HttpRequestCrt
1717

1818
/**
1919
* Convert an [HttpRequestBuilder] into a CRT HttpRequest for the purpose of signing.
2020
*/
21-
@InternalSdkApi
21+
@InternalApi
2222
public suspend fun HttpRequestBuilder.toSignableCrtRequest(unsignedPayload: Boolean = false): HttpRequestCrt {
2323
// Streams that implement HttpBody.Streaming and are not replayable are not signable without consuming the stream
2424
// and would need to go through chunked signing or unsigned payload
@@ -49,7 +49,7 @@ private suspend fun signableBodyStream(body: HttpBody): HttpRequestBodyStream? =
4949
/**
5050
* Convert an [HttpRequest] into a CRT HttpRequest for the purposes of signing
5151
*/
52-
@InternalSdkApi
52+
@InternalApi
5353
public suspend fun HttpRequest.toSignableCrtRequest(): HttpRequestCrt =
5454
HttpRequestCrt(
5555
method = method.name,
@@ -70,7 +70,7 @@ private class HttpHeadersCrt(val headers: HeadersBuilder) : HeadersCrt {
7070
/**
7171
* Update a request builder from a CRT HTTP request (primary use is updating a request builder after signing)
7272
*/
73-
@InternalSdkApi
73+
@InternalApi
7474
public fun HttpRequestBuilder.update(crtRequest: HttpRequestCrt) {
7575
crtRequest.headers.entries().forEach { entry ->
7676
headers.appendMissing(entry.key, entry.value)
@@ -94,7 +94,7 @@ public fun HttpRequestBuilder.update(crtRequest: HttpRequestCrt) {
9494
* Get just the query parameters (if any)
9595
* @return the query parameters from the path or null if there weren't any
9696
*/
97-
@InternalSdkApi
97+
@InternalApi
9898
public fun HttpRequestCrt.queryParameters(): QueryParameters? {
9999
val idx = encodedPath.indexOf("?")
100100
if (idx < 0 || idx + 1 > encodedPath.length) return null
@@ -108,14 +108,14 @@ public fun HttpRequestCrt.queryParameters(): QueryParameters? {
108108
* Get just the encoded path sans any query or fragment
109109
* @return the URI path segment from the encoded path
110110
*/
111-
@InternalSdkApi
111+
@InternalApi
112112
public fun HttpRequestCrt.path(): String {
113113
val idx = encodedPath.indexOf("?")
114114
return if (idx > 0) encodedPath.substring(0, idx) else encodedPath
115115
}
116116

117117
// Convert CRT header type to SDK header type
118-
@InternalSdkApi
118+
@InternalApi
119119
public fun aws.sdk.kotlin.crt.http.Headers.toSdkHeaders(): Headers {
120120
val headersBuilder = HeadersBuilder()
121121

@@ -127,7 +127,7 @@ public fun aws.sdk.kotlin.crt.http.Headers.toSdkHeaders(): Headers {
127127
}
128128

129129
// Convert SDK header type to CRT header type
130-
@InternalSdkApi
130+
@InternalApi
131131
public fun Headers.toCrtHeaders(): aws.sdk.kotlin.crt.http.Headers {
132132
val headersBuilder = aws.sdk.kotlin.crt.http.HeadersBuilder()
133133

runtime/crt-util/common/src/aws/sdk/kotlin/runtime/crt/ReadChannelBodyStream.kt renamed to runtime/crt-util/common/src/aws/smithy/kotlin/runtime/crt/ReadChannelBodyStream.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
* SPDX-License-Identifier: Apache-2.0.
44
*/
55

6-
package aws.sdk.kotlin.runtime.crt
6+
package aws.smithy.kotlin.runtime.crt
77

88
import aws.sdk.kotlin.crt.http.HttpRequestBodyStream
99
import aws.sdk.kotlin.crt.io.MutableBuffer
10-
import aws.sdk.kotlin.runtime.InternalSdkApi
1110
import aws.smithy.kotlin.runtime.io.SdkByteBuffer
1211
import aws.smithy.kotlin.runtime.io.SdkByteReadChannel
1312
import aws.smithy.kotlin.runtime.io.readAvailable
13+
import aws.smithy.kotlin.runtime.util.InternalApi
1414
import kotlinx.atomicfu.atomic
1515
import kotlinx.coroutines.*
1616
import kotlinx.coroutines.channels.Channel
@@ -24,7 +24,7 @@ internal expect fun transferRequestBody(outgoing: SdkByteBuffer, dest: MutableBu
2424
/**
2525
* Implement's [HttpRequestBodyStream] which proxies an SDK request body channel [SdkByteReadChannel]
2626
*/
27-
@InternalSdkApi
27+
@InternalApi
2828
public class ReadChannelBodyStream(
2929
// the request body channel
3030
private val bodyChan: SdkByteReadChannel,
@@ -49,9 +49,8 @@ public class ReadChannelBodyStream(
4949
// and handle these concerns.
5050
override fun resetPosition(): Boolean = true
5151

52-
override fun sendRequestBody(buffer: MutableBuffer): Boolean {
53-
return doSendRequestBody(buffer).also { if (it) producerJob.complete() }
54-
}
52+
override fun sendRequestBody(buffer: MutableBuffer): Boolean =
53+
doSendRequestBody(buffer).also { if (it) producerJob.complete() }
5554

5655
@OptIn(ExperimentalCoroutinesApi::class)
5756
private fun doSendRequestBody(buffer: MutableBuffer): Boolean {

runtime/crt-util/common/src/aws/sdk/kotlin/runtime/crt/SdkDefaultIO.kt renamed to runtime/crt-util/common/src/aws/smithy/kotlin/runtime/crt/SdkDefaultIO.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
* SPDX-License-Identifier: Apache-2.0.
44
*/
55

6-
package aws.sdk.kotlin.runtime.crt
6+
package aws.smithy.kotlin.runtime.crt
77

88
import aws.sdk.kotlin.crt.io.*
9-
import aws.sdk.kotlin.runtime.InternalSdkApi
9+
import aws.smithy.kotlin.runtime.util.InternalApi
1010

1111
// FIXME - this should default to number of processors
1212
private const val DEFAULT_EVENT_LOOP_THREAD_COUNT: Int = 1
1313

1414
/**
1515
* Default (CRT) IO used by the SDK when not configured manually/directly
1616
*/
17-
@InternalSdkApi
17+
@InternalApi
1818
public object SdkDefaultIO {
1919
/**
2020
* The default event loop group to run IO on

runtime/crt-util/common/test/aws/sdk/kotlin/runtime/crt/HttpTest.kt renamed to runtime/crt-util/common/test/aws/smithy/kotlin/runtime/crt/HttpTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0.
44
*/
55

6-
package aws.sdk.kotlin.runtime.crt
6+
package aws.smithy.kotlin.runtime.crt
77

88
import aws.smithy.kotlin.runtime.http.HttpMethod
99
import aws.smithy.kotlin.runtime.http.Protocol

runtime/crt-util/common/test/aws/sdk/kotlin/runtime/crt/ReadChannelBodyStreamTest.kt renamed to runtime/crt-util/common/test/aws/smithy/kotlin/runtime/crt/ReadChannelBodyStreamTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0.
44
*/
55

6-
package aws.sdk.kotlin.runtime.crt
6+
package aws.smithy.kotlin.runtime.crt
77

88
import aws.sdk.kotlin.crt.io.MutableBuffer
99
import aws.smithy.kotlin.runtime.io.SdkByteChannel

runtime/crt-util/jvm/src/aws/sdk/kotlin/runtime/crt/RequestUtilsJVM.kt renamed to runtime/crt-util/jvm/src/aws/smithy/kotlin/runtime/crt/RequestUtilsJVM.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0.
44
*/
55

6-
package aws.sdk.kotlin.runtime.crt
6+
package aws.smithy.kotlin.runtime.crt
77

88
import aws.sdk.kotlin.crt.io.MutableBuffer
99
import aws.smithy.kotlin.runtime.io.SdkByteBuffer

runtime/protocol/http-client-engines/http-client-engine-crt/build.gradle.kts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,35 @@ apply(plugin = "kotlinx-atomicfu")
1717

1818
description = "HTTP client engine backed by CRT"
1919
extra["displayName"] = "AWS :: SDK :: Kotlin :: HTTP"
20-
extra["moduleName"] = "aws.sdk.kotlin.runtime.http.engine.crt"
20+
extra["moduleName"] = "aws.smithy.kotlin.runtime.http.engine.crt"
2121

22-
val smithyKotlinVersion: String by project
2322
val coroutinesVersion: String by project
2423
val atomicFuVersion: String by project
2524

2625
kotlin {
2726
sourceSets {
2827
commonMain {
2928
dependencies {
30-
api(project(":aws-runtime:aws-core"))
31-
api("aws.smithy.kotlin:http:$smithyKotlinVersion")
32-
implementation("aws.smithy.kotlin:logging:$smithyKotlinVersion")
33-
implementation(project(":aws-runtime:crt-util"))
34-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
29+
api(project(":runtime:runtime-core"))
30+
api(project(":runtime:protocol:http"))
31+
implementation(project(":runtime:logging"))
32+
implementation(project(":runtime:crt-util"))
3533

34+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
3635
implementation("org.jetbrains.kotlinx:atomicfu:$atomicFuVersion")
3736
}
3837
}
3938

4039
commonTest {
4140
dependencies {
42-
implementation(project(":aws-runtime:testing"))
41+
implementation(project(":runtime:testing"))
42+
implementation(project(":runtime:protocol:http-test"))
4343
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
44-
implementation("aws.smithy.kotlin:http-test:$smithyKotlinVersion")
4544
}
4645
}
4746

4847
all {
4948
languageSettings.optIn("aws.smithy.kotlin.runtime.util.InternalApi")
50-
languageSettings.optIn("aws.sdk.kotlin.runtime.InternalSdkApi")
5149
}
5250
}
5351
}

0 commit comments

Comments
 (0)