Skip to content

Commit

Permalink
Delete dead code and add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoh committed Oct 17, 2023
1 parent e9ea121 commit 88718ee
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 30 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,9 @@ message = "`RuntimeComponents` have been added as an argument to the `IdentityRe
references = ["smithy-rs#2917"]
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client"}
author = "jdisanti"

[[smithy-rs]]
message = "The `idempotency_provider` field has been removed from config as a public field. If you need access to this field, it is still available from the context of an interceptor."
references = ["smithy-rs#3072"]
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client" }
author = "rcoh"
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.writable
import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext
import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType.Companion.preludeScope
import software.amazon.smithy.rust.codegen.core.smithy.isOptional
import software.amazon.smithy.rust.codegen.core.util.UNREACHABLE
import software.amazon.smithy.rust.codegen.core.util.findMemberWithTrait
import software.amazon.smithy.rust.codegen.core.util.inputShape

Expand Down Expand Up @@ -54,38 +55,25 @@ class IdempotencyTokenGenerator(
return when (section) {
is OperationSection.AdditionalRuntimePlugins -> writable {
section.addClientPlugin(this) {
if (symbolProvider.toSymbol(idempotencyTokenMember).isOptional()) {
// An idempotency token is optional. If the user didn't specify a token
// then we'll generate one and set it.
rustTemplate(
"""
#{IdempotencyTokenRuntimePlugin}::new(|token_provider, input| {
let input: &mut #{Input} = input.downcast_mut().expect("correct type");
if input.$memberName.is_none() {
input.$memberName = #{Some}(token_provider.make_idempotency_token());
}
})
""",
*codegenScope,
)
} else {
// An idempotency token is required, but it'll be set to an empty string if
// the user didn't specify one. If that's the case, then we'll generate one
// and set it.
rustTemplate(
"""
#{IdempotencyTokenRuntimePlugin}::new(|token_provider, input| {
let input: &mut #{Input} = input.downcast_mut().expect("correct type");
if input.$memberName.is_empty() {
input.$memberName = token_provider.make_idempotency_token();
}
})
""",
*codegenScope,
)
if (!symbolProvider.toSymbol(idempotencyTokenMember).isOptional()) {
UNREACHABLE("top level input members are always optional")
}
// An idempotency token is optional. If the user didn't specify a token
// then we'll generate one and set it.
rustTemplate(
"""
#{IdempotencyTokenRuntimePlugin}::new(|token_provider, input| {
let input: &mut #{Input} = input.downcast_mut().expect("correct type");
if input.$memberName.is_none() {
input.$memberName = #{Some}(token_provider.make_idempotency_token());
}
})
""",
*codegenScope,
)
}
}

else -> emptySection
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class IdempotencyTokenProviderCustomization(codegenContext: ClientCodegenContext
private val runtimeConfig = codegenContext.runtimeConfig
private val codegenScope = arrayOf(
*preludeScope,
"default_provider" to RuntimeType.idempotencyToken(runtimeConfig).resolve("default_provider"),
"IdempotencyTokenProvider" to RuntimeType.idempotencyToken(runtimeConfig).resolve("IdempotencyTokenProvider"),
)

Expand Down

0 comments on commit 88718ee

Please sign in to comment.