Skip to content

Commit

Permalink
Merge pull request #97 from amzn/awsclientinvocationdelegate_factory_…
Browse files Browse the repository at this point in the history
…method

Use the AWSClientInvocationDelegate factory function
  • Loading branch information
tachyonics authored Dec 18, 2023
2 parents 0ad25ea + 1bcc83a commit 49c7c32
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/SmokeAWSGenerate/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func generatePackageFile(baseNames: [String]) -> String {
.package(url: "https://github.com/apple/swift-metrics.git", "1.0.0"..<"3.0.0"),
.package(url: "https://github.com/LiveUI/XMLCoding.git", from: "0.4.1"),
.package(url: "https://github.com/amzn/smoke-http.git", from: "2.19.1"),
.package(url: "https://github.com/amzn/smoke-aws-support.git", from: "1.0.0"),
.package(url: "https://github.com/amzn/smoke-aws-support.git", from: "1.7.0"),
.package(url: "https://github.com/apple/swift-crypto.git", from: "1.0.0"),
],
targets: [\n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,19 @@ internal extension AWSClientDelegate {
fileBuilder.incIndent()

let typeName = function.name.getNormalizedTypeName(forModel: codeGenerator.model)

let initializerPrefix: String
let initializerPostfix: String
if case .asyncFunction = invokeType {
initializerPrefix = "try await "
initializerPostfix = ".get"
} else {
initializerPrefix = ""
initializerPostfix = ""
}

fileBuilder.appendLine("""
let handlerDelegate = AWSClientInvocationDelegate(
let handlerDelegate = \(initializerPrefix)AWSClientInvocationDelegate\(initializerPostfix)(
credentialsProvider: credentialsProvider,
awsRegion: awsRegion,
service: service,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,18 @@ internal extension AWSClientDelegate {
wrappedTypeDeclaration = "NoHTTPRequestInput(encodable: input)"
}

let initializerPrefix: String
let initializerPostfix: String
if case .asyncFunction = invokeType {
initializerPrefix = "try await "
initializerPostfix = ".get"
} else {
initializerPrefix = ""
initializerPostfix = ""
}

fileBuilder.appendLine("""
let handlerDelegate = AWSClientInvocationDelegate(
let handlerDelegate = \(initializerPrefix)AWSClientInvocationDelegate\(initializerPostfix)(
credentialsProvider: credentialsProvider,
awsRegion: awsRegion,
service: service,
Expand Down

0 comments on commit 49c7c32

Please sign in to comment.