Skip to content

Commit 48deed8

Browse files
committed
address pr reviews
1 parent b205cb1 commit 48deed8

File tree

6 files changed

+44
-6
lines changed

6 files changed

+44
-6
lines changed

codegen/smithy-aws-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/aws/customization/RegionSupport.kt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ class RegionSupport : KotlinIntegration {
4343
The region to sign with and make requests to.
4444
""".trimIndent()
4545
}
46+
47+
val RegionProviderProp: ConfigProperty = ConfigProperty {
48+
name = "regionProvider"
49+
symbol = RuntimeTypes.SmithyClient.Region.RegionProvider.asNullable()
50+
documentation = """
51+
An optional region provider that determines the AWS region for client operations. When specified, this provider
52+
takes precedence over the default region provider chain, unless a static region is explicitly configured.
53+
The region resolution order is:
54+
1. Static region (if specified)
55+
2. Custom region provider (if configured)
56+
3. Default region provider chain
57+
""".trimIndent()
58+
}
4659
}
4760

4861
// Allow other integrations to customize the service config props, later integrations take precedence.
@@ -57,8 +70,10 @@ class RegionSupport : KotlinIntegration {
5770
return supportsSigv4 || hasRegionBuiltin || isAwsSdk
5871
}
5972

60-
override fun additionalServiceConfigProps(ctx: CodegenContext): List<ConfigProperty> = listOf(RegionProp)
61-
73+
override fun additionalServiceConfigProps(ctx: CodegenContext): List<ConfigProperty> = buildList {
74+
add(RegionProp)
75+
add(RegionProviderProp)
76+
}
6277
override fun customizeEndpointResolution(ctx: ProtocolGenerator.GenerationContext): EndpointCustomization =
6378
object : EndpointCustomization {
6479
override fun renderBindEndpointBuiltins(

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/core/KotlinDependency.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ private fun getDefaultRuntimeVersion(): String {
3838
const val RUNTIME_GROUP: String = "aws.smithy.kotlin"
3939
val RUNTIME_VERSION: String = System.getProperty("smithy.kotlin.codegen.clientRuntimeVersion", getDefaultRuntimeVersion())
4040
val KOTLIN_COMPILER_VERSION: String = System.getProperty("smithy.kotlin.codegen.kotlinCompilerVersion", "2.0.10")
41-
val KOTLINX_COROUTINES_VERSION: String = System.getProperty("smithy.kotlin.codegen.kotlinCoroutinesVersion", "1.9.0")
4241

4342
enum class SourceSet {
4443
CommonMain,
@@ -135,7 +134,6 @@ data class KotlinDependency(
135134
// External third-party dependencies
136135
val KOTLIN_STDLIB = KotlinDependency(GradleConfiguration.Implementation, "kotlin", "org.jetbrains.kotlin", "kotlin-stdlib", KOTLIN_COMPILER_VERSION)
137136
val KOTLIN_TEST = KotlinDependency(GradleConfiguration.TestImplementation, "kotlin.test", "org.jetbrains.kotlin", "kotlin-test", KOTLIN_COMPILER_VERSION)
138-
val KOTLINX_COROUTINES = KotlinDependency(GradleConfiguration.Implementation, "kotlinx.coroutines", "org.jetbrains.kotlinx", "kotlinx-coroutines-core", KOTLINX_COROUTINES_VERSION)
139137
}
140138

141139
override fun getDependencies(): List<SymbolDependency> {

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/core/RuntimeTypes.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ object RuntimeTypes {
247247
val Url = symbol("Url")
248248
}
249249
}
250+
251+
object Region : RuntimeTypePackage(KotlinDependency.SMITHY_CLIENT, "region") {
252+
val RegionProvider = symbol("RegionProvider")
253+
}
250254
}
251255

252256
object Serde : RuntimeTypePackage(KotlinDependency.SERDE) {
@@ -409,6 +413,7 @@ object RuntimeTypes {
409413

410414
val CompletableDeferred = "kotlinx.coroutines.CompletableDeferred".toSymbol()
411415
val job = "kotlinx.coroutines.job".toSymbol()
416+
val runBlocking = "kotlinx.coroutines.runBlocking".toSymbol()
412417

413418
object Flow {
414419
// NOTE: smithy-kotlin core has an API dependency on this already

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/lang/KotlinTypes.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ object KotlinTypes {
118118
val minutes = stdlibSymbol("minutes", "time.Duration.Companion")
119119
}
120120

121-
object Coroutines : RuntimeTypePackage(KotlinDependency.KOTLINX_COROUTINES) {
122-
val runBlocking = symbol("runBlocking")
121+
object Coroutines {
123122
val CoroutineContext = "kotlin.coroutines.CoroutineContext".toSymbol()
124123
}
125124

runtime/smithy-client/api/smithy-client.api

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,7 @@ public final class aws/smithy/kotlin/runtime/client/endpoints/functions/Url {
325325
public fun toString ()Ljava/lang/String;
326326
}
327327

328+
public abstract interface class aws/smithy/kotlin/runtime/client/region/RegionProvider {
329+
public abstract fun getRegion (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
330+
}
331+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package aws.smithy.kotlin.runtime.client.region
7+
8+
/**
9+
* Interface for providing AWS region information. Implementations are free to use any strategy for
10+
* providing region information
11+
*/
12+
public interface RegionProvider {
13+
/**
14+
* Return the region name to use. If region information is not available, implementations should return null
15+
*/
16+
public suspend fun getRegion(): String?
17+
}

0 commit comments

Comments
 (0)