Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Move retry middleware out #806

Merged
merged 6 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 0 additions & 79 deletions AWSClientRuntime/Sources/Middlewares/RetryerMiddleware.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ object AWSClientRuntimeTypes {
val AWSUserAgentMetadata = runtimeSymbol("AWSUserAgentMetadata")
val APIMetadata = runtimeSymbol("APIMetadata")
val UserAgentMiddleware = runtimeSymbol("UserAgentMiddleware")
val RetryerMiddleware = runtimeSymbol("RetryerMiddleware")
val EndpointResolverMiddleware = runtimeSymbol("EndpointResolverMiddleware")
val FrameworkMetadata = runtimeSymbol("FrameworkMetadata")
val CredentialsProvider = runtimeSymbol("CredentialsProvider")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package software.amazon.smithy.aws.swift.codegen

import software.amazon.smithy.aws.swift.codegen.middleware.AWSSigningMiddleware
import software.amazon.smithy.aws.swift.codegen.middleware.OperationEndpointResolverMiddleware
import software.amazon.smithy.aws.swift.codegen.middleware.RetryMiddleware
import software.amazon.smithy.aws.swift.codegen.middleware.UserAgentMiddleware
import software.amazon.smithy.codegen.core.Symbol
import software.amazon.smithy.model.shapes.MemberShape
Expand All @@ -24,6 +23,7 @@ import software.amazon.smithy.swift.codegen.integration.HttpProtocolUnitTestGene
import software.amazon.smithy.swift.codegen.integration.HttpProtocolUnitTestRequestGenerator
import software.amazon.smithy.swift.codegen.integration.HttpProtocolUnitTestResponseGenerator
import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator
import software.amazon.smithy.swift.codegen.integration.middlewares.RetryMiddleware
import software.amazon.smithy.swift.codegen.integration.serde.json.StructDecodeGenerator
import software.amazon.smithy.swift.codegen.integration.serde.json.StructEncodeGenerator
import software.amazon.smithy.swift.codegen.model.ShapeMetadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ class AWSServiceConfig(writer: SwiftWriter, val ctx: ProtocolGenerator.Generatio
writer.dedent()
writer.write("}")
writer.write("")
writer.openBlock("public var partitionID: String? {", "}") {
writer.write("return [\"\$L\", region].compactMap { $$0 }.joined(separator: \" - \")", serviceName)
}
}

override fun otherRuntimeConfigProperties(): List<ConfigField> {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class PresignerGeneratorTests {
.withOperation(value: "getFoo")
.withIdempotencyTokenGenerator(value: config.idempotencyTokenGenerator)
.withLogger(value: config.logger)
.withPartitionID(value: config.partitionID)
.withCredentialsProvider(value: config.credentialsProvider)
.withRegion(value: config.region)
.withSigningName(value: "example-signing-name")
Expand All @@ -48,7 +49,7 @@ class PresignerGeneratorTests {
operation.buildStep.intercept(position: .before, middleware: EndpointResolverMiddleware<GetFooOutputResponse, GetFooOutputError>(endpointResolver: config.endpointResolver, endpointParams: endpointParams))
let apiMetadata = AWSClientRuntime.APIMetadata(serviceId: serviceName, version: "1.0.0")
operation.buildStep.intercept(position: .before, middleware: AWSClientRuntime.UserAgentMiddleware(metadata: AWSClientRuntime.AWSUserAgentMetadata.fromEnv(apiMetadata: apiMetadata, frameworkMetadata: config.frameworkMetadata)))
operation.finalizeStep.intercept(position: .after, middleware: AWSClientRuntime.RetryerMiddleware<GetFooOutputResponse, GetFooOutputError>(retryer: config.retryer))
operation.finalizeStep.intercept(position: .after, middleware: ClientRuntime.RetryerMiddleware<GetFooOutputResponse, GetFooOutputError>(retryer: config.retryer))
let sigv4Config = AWSClientRuntime.SigV4Config(expiration: expiration, unsignedBody: false)
operation.finalizeStep.intercept(position: .before, middleware: AWSClientRuntime.SigV4Middleware<GetFooOutputResponse, GetFooOutputError>(config: sigv4Config))
operation.deserializeStep.intercept(position: .before, middleware: ClientRuntime.LoggerMiddleware<GetFooOutputResponse, GetFooOutputError>(clientLogMode: config.clientLogMode))
Expand Down Expand Up @@ -92,6 +93,7 @@ class PresignerGeneratorTests {
.withOperation(value: "postFoo")
.withIdempotencyTokenGenerator(value: config.idempotencyTokenGenerator)
.withLogger(value: config.logger)
.withPartitionID(value: config.partitionID)
.withCredentialsProvider(value: config.credentialsProvider)
.withRegion(value: config.region)
.withSigningName(value: "example-signing-name")
Expand All @@ -106,7 +108,7 @@ class PresignerGeneratorTests {
operation.serializeStep.intercept(position: .after, middleware: ContentTypeMiddleware<PostFooInput, PostFooOutputResponse>(contentType: "application/json"))
operation.serializeStep.intercept(position: .after, middleware: ClientRuntime.SerializableBodyMiddleware<PostFooInput, PostFooOutputResponse>(xmlName: "GetFooInput"))
operation.finalizeStep.intercept(position: .before, middleware: ClientRuntime.ContentLengthMiddleware())
operation.finalizeStep.intercept(position: .after, middleware: AWSClientRuntime.RetryerMiddleware<PostFooOutputResponse, PostFooOutputError>(retryer: config.retryer))
operation.finalizeStep.intercept(position: .after, middleware: ClientRuntime.RetryerMiddleware<PostFooOutputResponse, PostFooOutputError>(retryer: config.retryer))
let sigv4Config = AWSClientRuntime.SigV4Config(expiration: expiration, unsignedBody: false)
operation.finalizeStep.intercept(position: .before, middleware: AWSClientRuntime.SigV4Middleware<PostFooOutputResponse, PostFooOutputError>(config: sigv4Config))
operation.deserializeStep.intercept(position: .before, middleware: ClientRuntime.LoggerMiddleware<PostFooOutputResponse, PostFooOutputError>(clientLogMode: config.clientLogMode))
Expand Down Expand Up @@ -150,6 +152,7 @@ class PresignerGeneratorTests {
.withOperation(value: "putFoo")
.withIdempotencyTokenGenerator(value: config.idempotencyTokenGenerator)
.withLogger(value: config.logger)
.withPartitionID(value: config.partitionID)
.withCredentialsProvider(value: config.credentialsProvider)
.withRegion(value: config.region)
.withSigningName(value: "example-signing-name")
Expand All @@ -164,7 +167,7 @@ class PresignerGeneratorTests {
operation.serializeStep.intercept(position: .after, middleware: ContentTypeMiddleware<PutFooInput, PutFooOutputResponse>(contentType: "application/json"))
operation.serializeStep.intercept(position: .after, middleware: ClientRuntime.SerializableBodyMiddleware<PutFooInput, PutFooOutputResponse>(xmlName: "GetFooInput"))
operation.finalizeStep.intercept(position: .before, middleware: ClientRuntime.ContentLengthMiddleware())
operation.finalizeStep.intercept(position: .after, middleware: AWSClientRuntime.RetryerMiddleware<PutFooOutputResponse, PutFooOutputError>(retryer: config.retryer))
operation.finalizeStep.intercept(position: .after, middleware: ClientRuntime.RetryerMiddleware<PutFooOutputResponse, PutFooOutputError>(retryer: config.retryer))
let sigv4Config = AWSClientRuntime.SigV4Config(expiration: expiration, unsignedBody: false)
operation.finalizeStep.intercept(position: .before, middleware: AWSClientRuntime.SigV4Middleware<PutFooOutputResponse, PutFooOutputError>(config: sigv4Config))
operation.deserializeStep.intercept(position: .before, middleware: ClientRuntime.LoggerMiddleware<PutFooOutputResponse, PutFooOutputError>(clientLogMode: config.clientLogMode))
Expand Down Expand Up @@ -210,6 +213,7 @@ class PresignerGeneratorTests {
.withOperation(value: "putObject")
.withIdempotencyTokenGenerator(value: config.idempotencyTokenGenerator)
.withLogger(value: config.logger)
.withPartitionID(value: config.partitionID)
.withCredentialsProvider(value: config.credentialsProvider)
.withRegion(value: config.region)
.withSigningName(value: "s3")
Expand All @@ -224,7 +228,7 @@ class PresignerGeneratorTests {
operation.serializeStep.intercept(position: .after, middleware: ContentTypeMiddleware<PutObjectInput, PutObjectOutputResponse>(contentType: "application/json"))
operation.serializeStep.intercept(position: .after, middleware: ClientRuntime.SerializableBodyMiddleware<PutObjectInput, PutObjectOutputResponse>(xmlName: "PutObjectInput"))
operation.finalizeStep.intercept(position: .before, middleware: ClientRuntime.ContentLengthMiddleware())
operation.finalizeStep.intercept(position: .after, middleware: AWSClientRuntime.RetryerMiddleware<PutObjectOutputResponse, PutObjectOutputError>(retryer: config.retryer))
operation.finalizeStep.intercept(position: .after, middleware: ClientRuntime.RetryerMiddleware<PutObjectOutputResponse, PutObjectOutputError>(retryer: config.retryer))
let sigv4Config = AWSClientRuntime.SigV4Config(useDoubleURIEncode: false, shouldNormalizeURIPath: false, expiration: expiration, signedBodyHeader: .contentSha256, unsignedBody: false)
operation.finalizeStep.intercept(position: .before, middleware: AWSClientRuntime.SigV4Middleware<PutObjectOutputResponse, PutObjectOutputError>(config: sigv4Config))
operation.deserializeStep.intercept(position: .before, middleware: ClientRuntime.LoggerMiddleware<PutObjectOutputResponse, PutObjectOutputError>(clientLogMode: config.clientLogMode))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ class RestJsonProtocolGeneratorTests {
useFIPS: useFIPS
)
}


public var partitionID: String? {
return ["ExampleClient", region].compactMap { ${'$'}0 }.joined(separator: " - ")
jbelkins marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class AWSQueryOperationStackTest {
.withOperation(value: "noInputAndOutput")
.withIdempotencyTokenGenerator(value: config.idempotencyTokenGenerator)
.withLogger(value: config.logger)
.withPartitionID(value: config.partitionID)
.withCredentialsProvider(value: config.credentialsProvider)
.withRegion(value: config.region)
var operation = ClientRuntime.OperationStack<NoInputAndOutputInput, NoInputAndOutputOutputResponse, NoInputAndOutputOutputError>(id: "noInputAndOutput")
Expand All @@ -43,7 +44,7 @@ class AWSQueryOperationStackTest {
operation.serializeStep.intercept(position: .after, middleware: ClientRuntime.SerializableBodyMiddleware<NoInputAndOutputInput, NoInputAndOutputOutputResponse>(xmlName: "NoInputAndOutputInput"))
operation.serializeStep.intercept(position: .after, middleware: ContentTypeMiddleware<NoInputAndOutputInput, NoInputAndOutputOutputResponse>(contentType: "application/x-www-form-urlencoded"))
operation.finalizeStep.intercept(position: .before, middleware: ClientRuntime.ContentLengthMiddleware())
operation.finalizeStep.intercept(position: .after, middleware: AWSClientRuntime.RetryerMiddleware<NoInputAndOutputOutputResponse, NoInputAndOutputOutputError>(retryer: config.retryer))
operation.finalizeStep.intercept(position: .after, middleware: ClientRuntime.RetryerMiddleware<NoInputAndOutputOutputResponse, NoInputAndOutputOutputError>(retryer: config.retryer))
operation.deserializeStep.intercept(position: .before, middleware: ClientRuntime.LoggerMiddleware<NoInputAndOutputOutputResponse, NoInputAndOutputOutputError>(clientLogMode: config.clientLogMode))
operation.deserializeStep.intercept(position: .after, middleware: ClientRuntime.DeserializeMiddleware<NoInputAndOutputOutputResponse, NoInputAndOutputOutputError>())
let result = try await operation.handleMiddleware(context: context.build(), input: input, next: client.getHandler())
Expand Down