Skip to content

Commit dfa21d4

Browse files
authored
feat!: Modularize event streams & event streams auth (#741)
1 parent b1e14ef commit dfa21d4

File tree

387 files changed

+3931
-1939
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

387 files changed

+3931
-1939
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ jobs:
112112
cd ../aws-sdk-swift
113113
set -o pipefail && \
114114
NSUnbufferedIO=YES xcodebuild \
115-
-scheme aws-sdk-swift \
115+
-scheme aws-sdk-swift-Package \
116116
-destination '${{ matrix.destination }}' \
117117
test 2>&1 \
118118
| xcbeautify

Package.swift

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,51 @@ let package = Package(
2828
.watchOS(.v6)
2929
],
3030
products: [
31+
.library(name: "Smithy", targets: ["Smithy"]),
3132
.library(name: "ClientRuntime", targets: ["ClientRuntime"]),
3233
.library(name: "SmithyRetriesAPI", targets: ["SmithyRetriesAPI"]),
3334
.library(name: "SmithyRetries", targets: ["SmithyRetries"]),
3435
.library(name: "SmithyReadWrite", targets: ["SmithyReadWrite"]),
3536
.library(name: "SmithyXML", targets: ["SmithyXML"]),
3637
.library(name: "SmithyJSON", targets: ["SmithyJSON"]),
3738
.library(name: "SmithyFormURL", targets: ["SmithyFormURL"]),
39+
.library(name: "SmithyIdentityAPI", targets: ["SmithyIdentityAPI"]),
40+
.library(name: "SmithyHTTPAPI", targets: ["SmithyHTTPAPI"]),
41+
.library(name: "SmithyHTTPAuthAPI", targets: ["SmithyHTTPAuthAPI"]),
42+
.library(name: "SmithyEventStreamsAPI", targets: ["SmithyEventStreamsAPI"]),
43+
.library(name: "SmithyEventStreamsAuthAPI", targets: ["SmithyEventStreamsAuthAPI"]),
44+
.library(name: "SmithyEventStreams", targets: ["SmithyEventStreams"]),
45+
.library(name: "SmithyChecksumsAPI", targets: ["SmithyChecksumsAPI"]),
3846
.library(name: "SmithyTestUtil", targets: ["SmithyTestUtil"]),
3947
],
4048
dependencies: [
4149
.package(url: "https://github.com/awslabs/aws-crt-swift.git", exact: "0.30.0"),
4250
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
4351
],
4452
targets: [
53+
.target(
54+
name: "Smithy",
55+
dependencies: [
56+
.product(name: "Logging", package: "swift-log"),
57+
]
58+
),
4559
.target(
4660
name: "ClientRuntime",
4761
dependencies: [
62+
"Smithy",
4863
"SmithyRetriesAPI",
4964
"SmithyRetries",
5065
"SmithyXML",
5166
"SmithyJSON",
5267
"SmithyFormURL",
68+
"SmithyIdentityAPI",
69+
"SmithyHTTPAPI",
70+
"SmithyHTTPAuthAPI",
71+
"SmithyEventStreamsAPI",
72+
"SmithyEventStreams",
73+
"SmithyEventStreamsAuthAPI",
74+
"SmithyChecksumsAPI",
5375
.product(name: "AwsCommonRuntimeKit", package: "aws-crt-swift"),
54-
.product(name: "Logging", package: "swift-log"),
5576
],
5677
resources: [
5778
.copy("PrivacyInfo.xcprivacy")
@@ -73,9 +94,7 @@ let package = Package(
7394
),
7495
.target(
7596
name: "SmithyReadWrite",
76-
dependencies: [
77-
"SmithyTimestamps"
78-
]
97+
dependencies: ["SmithyTimestamps"]
7998
),
8099
.target(
81100
name: "SmithyXML",
@@ -107,6 +126,39 @@ let package = Package(
107126
name: "SmithyTestUtil",
108127
dependencies: ["ClientRuntime"]
109128
),
129+
.target(
130+
name: "SmithyIdentityAPI",
131+
dependencies: ["Smithy"]
132+
),
133+
.target(
134+
name: "SmithyHTTPAPI",
135+
dependencies: ["Smithy"]
136+
),
137+
.target(
138+
name: "SmithyHTTPAuthAPI",
139+
dependencies: ["Smithy", "SmithyHTTPAPI"]
140+
),
141+
.target(
142+
name: "SmithyEventStreamsAPI",
143+
dependencies: ["Smithy"]
144+
),
145+
.target(
146+
name: "SmithyEventStreamsAuthAPI",
147+
dependencies: ["Smithy", "SmithyEventStreamsAPI"]
148+
),
149+
.target(
150+
name: "SmithyEventStreams",
151+
dependencies: [
152+
"Smithy",
153+
"SmithyEventStreamsAPI",
154+
"SmithyEventStreamsAuthAPI",
155+
.product(name: "AwsCommonRuntimeKit", package: "aws-crt-swift")
156+
]
157+
),
158+
.target(
159+
name: "SmithyChecksumsAPI",
160+
dependencies: ["Smithy"]
161+
),
110162
.testTarget(
111163
name: "ClientRuntimeTests",
112164
dependencies: ["ClientRuntime", "SmithyTestUtil"],
@@ -132,6 +184,10 @@ let package = Package(
132184
name: "SmithyTestUtilTests",
133185
dependencies: ["SmithyTestUtil"]
134186
),
187+
.testTarget(
188+
name: "SmithyEventStreamsTests",
189+
dependencies: ["SmithyEventStreams"]
190+
),
135191
].compactMap { $0 }
136192
)
137193

Sources/ClientRuntime/Auth/HTTPAuth/DefaultIdentityResolverConfiguration.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8+
import struct Smithy.Attributes
9+
import struct Smithy.AttributeKey
10+
import protocol SmithyIdentityAPI.IdentityResolver
11+
import protocol SmithyIdentityAPI.IdentityResolverConfiguration
12+
813
public struct DefaultIdentityResolverConfiguration: IdentityResolverConfiguration {
914
let identityResolvers: Attributes
1015

1116
public init(configuredIdResolvers: Attributes) {
1217
self.identityResolvers = configuredIdResolvers
1318
}
1419

15-
func getIdentityResolver(schemeID: String) throws -> (any IdentityResolver)? {
20+
public func getIdentityResolver(schemeID: String) throws -> (any IdentityResolver)? {
1621
return self.identityResolvers.get(key: AttributeKey<any IdentityResolver>(name: schemeID))
1722
}
1823
}

Sources/ClientRuntime/Auth/HTTPAuthAPI/Signer.swift

Lines changed: 0 additions & 30 deletions
This file was deleted.

Sources/ClientRuntime/Config/DefaultHttpClientConfiguration.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8+
import protocol SmithyHTTPAPI.HTTPClient
9+
import protocol SmithyHTTPAuthAPI.AuthScheme
10+
import protocol SmithyHTTPAuthAPI.AuthSchemeResolver
11+
812
public protocol DefaultHttpClientConfiguration: ClientConfiguration {
913

1014
/// The HTTP client to be used for the target platform, configured with the supplied configuration.
@@ -19,10 +23,10 @@ public protocol DefaultHttpClientConfiguration: ClientConfiguration {
1923
/// List of auth schemes to use for client calls.
2024
///
2125
/// Defaults to auth schemes defined on the Smithy service model.
22-
var authSchemes: [ClientRuntime.AuthScheme]? { get set }
26+
var authSchemes: [AuthScheme]? { get set }
2327

2428
/// The auth scheme resolver to use for resolving auth scheme.
2529
///
2630
/// Defaults to a auth scheme resolver generated based on Smithy service model.
27-
var authSchemeResolver: ClientRuntime.AuthSchemeResolver { get set }
31+
var authSchemeResolver: AuthSchemeResolver { get set }
2832
}

Sources/ClientRuntime/Config/DefaultSDKRuntimeConfiguration.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8+
import class Smithy.Context
9+
import protocol SmithyHTTPAPI.HTTPClient
10+
import enum Smithy.ClientError
11+
import struct SmithyHTTPAuthAPI.AuthOption
12+
import protocol SmithyHTTPAuthAPI.AuthSchemeResolver
13+
import protocol SmithyHTTPAuthAPI.AuthSchemeResolverParameters
814
import protocol SmithyRetriesAPI.RetryStrategy
915
import protocol SmithyRetriesAPI.RetryErrorInfoProvider
1016
import struct SmithyRetriesAPI.RetryStrategyOptions
@@ -137,7 +143,7 @@ public class DefaultAuthSchemeResolver: AuthSchemeResolver {
137143
return []
138144
}
139145

140-
public func constructParameters(context: HttpContext) throws -> AuthSchemeResolverParameters {
146+
public func constructParameters(context: Context) throws -> AuthSchemeResolverParameters {
141147
guard let opName = context.getOperation() else {
142148
throw ClientError.dataNotFound(
143149
"Operation name not configured in middleware context for auth scheme resolver params construction.")

Sources/ClientRuntime/Endpoints/ServiceEndpointMetadata.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8+
import enum Smithy.URIScheme
9+
import struct SmithyHTTPAPI.Endpoint
10+
811
public struct ServiceEndpointMetadata {
9-
public let defaultProtocol = ProtocolType.https.rawValue
12+
public let defaultProtocol = URIScheme.https.rawValue
1013
public let defaultSigner = "v4"
11-
public let protocolPriority = ProtocolType.allCases.map { $0.rawValue }
14+
public let protocolPriority = URIScheme.allCases.map { $0.rawValue }
1215
public let signerPriority = ["v4"]
1316
/**
1417
A URI **template** used to resolve the hostname of the endpoint.
@@ -52,7 +55,7 @@ extension ServiceEndpointMetadata {
5255

5356
return SmithyEndpoint(endpoint: Endpoint(host: hostname,
5457
path: "/",
55-
protocolType: ProtocolType(rawValue: transportProtocol)!),
58+
protocolType: URIScheme(rawValue: transportProtocol)!),
5659
signingName: signingName)
5760
}
5861

Sources/ClientRuntime/Endpoints/SmithyEndpoint.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8+
import struct SmithyHTTPAPI.Endpoint
9+
810
/**
911
A structure used by the service client to determine the endpoint.
1012
The SDK will automatically resolve endpoints per API client using an internal resolver.

Sources/ClientRuntime/EventStream/MessageEncoderStream.swift

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import struct Smithy.AttributeKey
9+
import class Smithy.Context
10+
import class Smithy.ContextBuilder
11+
12+
extension Context {
13+
14+
public func getIdempotencyTokenGenerator() -> IdempotencyTokenGenerator {
15+
return attributes.get(key: idempotencyTokenGeneratorKey)!
16+
}
17+
}
18+
19+
extension ContextBuilder {
20+
21+
@discardableResult
22+
public func withIdempotencyTokenGenerator(value: IdempotencyTokenGenerator) -> Self {
23+
self.attributes.set(key: idempotencyTokenGeneratorKey, value: value)
24+
return self
25+
}
26+
}
27+
28+
private let idempotencyTokenGeneratorKey = AttributeKey<IdempotencyTokenGenerator>(name: "IdempotencyTokenGeneratorKey")

0 commit comments

Comments
 (0)