-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
528 additions
and
232 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
Packages/ClientRuntime/Sources/Config/DefaultSDKRuntimeConfiguration.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
public struct DefaultSDKRuntimeConfiguration: SDKRuntimeConfiguration { | ||
public var retrier: Retrier | ||
|
||
public var logger: LogAgent | ||
|
||
public init(_ clientName: String) throws { | ||
self.retrier = try SDKRetrier() | ||
self.logger = SwiftLogger(label: clientName) | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
Packages/ClientRuntime/Sources/Config/SDKRuntimeConfiguration.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
/// For each service, a concrete service client configuration class is generated to implement the SDKRuntimeConfiguration protocol. | ||
/// This generated concrete class provides a mechanism to adopt defaults or override by injection any of the parameters. | ||
/// If this concrete class is not sufficient for your use case, you have the ability to write a concrete class that conforms to SDKRuntimeConfiguration. | ||
public protocol SDKRuntimeConfiguration { | ||
var encoder: RequestEncoder? {get} | ||
var decoder: ResponseDecoder? {get} | ||
var httpClientEngine: HttpClientEngine {get} | ||
var httpClientConfiguration: HttpClientConfiguration {get} | ||
var idempotencyTokenGenerator: IdempotencyTokenGenerator {get} | ||
var retrier: Retrier {get} | ||
var logger: LogAgent {get} | ||
var clientLogMode: ClientLogMode {get} | ||
} | ||
|
||
public extension SDKRuntimeConfiguration { | ||
var httpClientEngine: HttpClientEngine { | ||
return CRTClientEngine() | ||
} | ||
|
||
var httpClientConfiguration: HttpClientConfiguration { | ||
return HttpClientConfiguration() | ||
} | ||
|
||
var idempotencyTokenGenerator: IdempotencyTokenGenerator { | ||
return DefaultIdempotencyTokenGenerator() | ||
} | ||
|
||
var clientLogMode: ClientLogMode { | ||
return .request | ||
} | ||
|
||
var encoder: RequestEncoder? { | ||
return nil | ||
} | ||
|
||
var decoder: ResponseDecoder? { | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
Packages/ClientRuntime/Sources/Networking/Http/CRT/SDKDefaultIO.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import AwsCommonRuntimeKit | ||
import class Foundation.ProcessInfo | ||
|
||
public final class SDKDefaultIO { | ||
public static let shared = SDKDefaultIO() | ||
|
||
public let eventLoopGroup: EventLoopGroup | ||
public let hostResolver: DefaultHostResolver | ||
public let clientBootstrap: ClientBootstrap | ||
public let tlsContext: TlsContext | ||
|
||
private init() { | ||
self.eventLoopGroup = EventLoopGroup(threadCount: 0) | ||
self.hostResolver = DefaultHostResolver(eventLoopGroup: eventLoopGroup, | ||
maxHosts: 8, | ||
maxTTL: 30) | ||
|
||
do { | ||
self.clientBootstrap = try ClientBootstrap(eventLoopGroup: eventLoopGroup, | ||
hostResolver: hostResolver) | ||
} catch { | ||
fatalError(""" | ||
Client Bootstrap failed to create. This could be due to lack | ||
of memory but should never happen. Please open a Github issue with | ||
us at https://github.com/awslabs/aws-sdk-swift. | ||
""") | ||
} | ||
|
||
let tlsContextOptions = TlsContextOptions() | ||
tlsContextOptions.setVerifyPeer(true) | ||
|
||
do { | ||
self.tlsContext = try TlsContext(options: tlsContextOptions, | ||
mode: .client) | ||
} catch { | ||
fatalError(""" | ||
Tls Context failed to create. This should never happen.Please open a | ||
Github issue with us at https://github.com/awslabs/aws-sdk-swift. | ||
""") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,4 +67,3 @@ extension ByteStream: Codable { | |
try container.encode(self.toBytes().toData()) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/ClientRuntimeTypes.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
package software.amazon.smithy.swift.codegen | ||
|
||
import software.amazon.smithy.codegen.core.Symbol | ||
import software.amazon.smithy.swift.codegen.model.buildSymbol | ||
|
||
/** | ||
* Commonly used runtime types. Provides a single definition of a runtime symbol such that codegen isn't littered | ||
* with inline symbol creation which makes refactoring of the runtime more difficult and error prone. | ||
* | ||
* NOTE: Not all symbols need be added here but it doesn't hurt to define runtime symbols once. | ||
*/ | ||
object ClientRuntimeTypes { | ||
object Http { | ||
val HttpClientEngine = runtimeSymbol("HttpClientEngine") | ||
val HttpClientConfiguration = runtimeSymbol("HttpClientConfiguration") | ||
} | ||
|
||
object Serde { | ||
val RequestEncoder = runtimeSymbol("RequestEncoder") | ||
val ResponseDecoder = runtimeSymbol("ResponseDecoder") | ||
} | ||
|
||
object Core { | ||
val Logger = runtimeSymbol("LogAgent") | ||
val ClientLogMode = runtimeSymbol("ClientLogMode") | ||
val IdempotencyTokenGenerator = runtimeSymbol("IdempotencyTokenGenerator") | ||
val Retrier = runtimeSymbol("Retrier") | ||
} | ||
} | ||
|
||
private fun runtimeSymbol(name: String): Symbol = buildSymbol { | ||
this.name = name | ||
dependency(SwiftDependency.CLIENT_RUNTIME) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.