-
Notifications
You must be signed in to change notification settings - Fork 80
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!: Modularize event streams & event streams auth #1530
Conversation
static var smithyEventStreamsAPI: Self { .product(name: "SmithyEventStreamsAPI", package: "smithy-swift") } | ||
static var smithyEventStreamsAuthAPI: Self { .product(name: "SmithyEventStreamsAuthAPI", package: "smithy-swift") } | ||
static var smithyEventStreams: Self { .product(name: "SmithyEventStreams", package: "smithy-swift") } | ||
static var smithyChecksumsAPI: Self { .product(name: "SmithyChecksumsAPI", package: "smithy-swift") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created several new modules in smithy-swift; they are added here as dependencies
.library(name: "AWSClientRuntime", targets: ["AWSClientRuntime"]), | ||
.library(name: "AWSSDKEventStreamsAuth", targets: ["AWSSDKEventStreamsAuth"]), | ||
.library(name: "AWSSDKIdentity", targets: ["AWSSDKIdentity"]), | ||
.library(name: "AWSSDKHTTPAuth", targets: ["AWSSDKHTTPAuth"]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several new AWS modules are added.
AWSSDKIdentity
and AWSSDKHTTPAuth
are likely not complete; enough types were added to them to allow event stream modularization.
@@ -105,14 +147,30 @@ func addDoccDependency() { | |||
|
|||
// MARK: - Services | |||
|
|||
let serviceTargetDependencies: [Target.Dependency] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This long list is broken into a variable so it can be shared between service client targets and protocol test targets.
@@ -21,6 +21,12 @@ extension Target.Dependency { | |||
static var clientRuntime: Self { .product(name: "ClientRuntime", package: "smithy-swift") } | |||
static var smithyRetriesAPI: Self { .product(name: "SmithyRetriesAPI", package: "smithy-swift") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is generated. See comments in the Package.Base.swift
above.
@@ -5,9 +5,10 @@ | |||
// SPDX-License-Identifier: Apache-2.0 | |||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many files, like this one, have import and type namespace adjustments. I won't comment on those every time they happen in the following files.
@@ -5,13 +5,14 @@ | |||
// SPDX-License-Identifier: Apache-2.0 | |||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AWSCredentialIdentity
(above) was moved out to smithy-swift
because SRA specifies that it should be there.
@@ -3,6 +3,7 @@ | |||
* SPDX-License-Identifier: Apache-2.0. | |||
*/ | |||
|
|||
import class SmithyHTTPAPI.HttpResponse | |||
import ClientRuntime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following files (the event stream files in AWSClientRuntime
) have been moved to smithy-swift since they are not actually AWS-specific.
@@ -18,8 +20,7 @@ public struct AWSS3ErrorWith200StatusXMLMiddleware<OperationStackInput, Operatio | |||
next: H) async throws -> OperationOutput<OperationStackOutput> | |||
where H: Handler, | |||
Self.MInput == H.Input, | |||
Self.MOutput == H.Output, | |||
Self.Context == H.Context { | |||
Self.MOutput == H.Output { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you will see later, Context
is removed as a generic type on both the Middleware
and Handler
protocols, because it does not need to be specialized.
@@ -1,9 +1,12 @@ | |||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | |||
// SPDX-License-Identifier: Apache-2.0. | |||
|
|||
import class Smithy.Context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HttpContext
was moved into the new Smithy
module and renamed to Context
since it is not specific to HTTP.
@@ -22,22 +22,3 @@ extension String { | |||
String(map { tokenNoHashCharacterSet.contains($0) ? $0 : substituteCharacter }) | |||
} | |||
} | |||
|
|||
extension String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This extension was moved since it is used with checksums.
|
||
extension AWSEventStream { | ||
/// Signs a `Message` using the AWS SigV4 signing algorithm | ||
public class AWSMessageSigner: MessageSigner { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the SigV4 signer for event streams. It is moved from AWSClientRuntime
to the new AWSSDKEventStreamsAuth
module.
import struct Foundation.Data | ||
import AwsCommonRuntimeKit | ||
|
||
extension AWSSigV4Signer: MessageDataSigner { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This extension was previously defined right on the signer. Moved it out separate so it could be packaged with event streams auth.
import SmithyEventStreams | ||
import SmithyEventStreamsAuthAPI | ||
|
||
extension Context { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some special functions on the Context
object to support event streams auth.
import AwsCommonRuntimeKit | ||
import ClientRuntime | ||
import Foundation | ||
|
||
public class AWSSigV4Signer: ClientRuntime.Signer { | ||
public class AWSSigV4Signer: SmithyHTTPAuthAPI.Signer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the regular signer for SigV4. It is split from AWSClientRuntime
to the new AWSSDKHTTPAuth
module.
@@ -127,18 +135,6 @@ public class AWSSigV4Signer: ClientRuntime.Signer { | |||
) | |||
} | |||
|
|||
public func signEvent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event signing methods on this signer were split off to an extension in the event streams auth module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 naming & 1 access level comment
@@ -35,7 +41,10 @@ let package = Package( | |||
.watchOS(.v6) | |||
], | |||
products: [ | |||
.library(name: "AWSClientRuntime", targets: ["AWSClientRuntime"]) | |||
.library(name: "AWSClientRuntime", targets: ["AWSClientRuntime"]), | |||
.library(name: "AWSSDKEventStreamsAuth", targets: ["AWSSDKEventStreamsAuth"]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naming: For the new modules, I think it would be better to name it AWSXYZ
instead of AWSSDKXYZ
given SDK
is redundant & AWSSDK
is harder to read with 2 S's back to back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good with either AWS
prefix or SDK
prefix. My preference is actually SDK
because I think it is more clear. I.e. this is our runtime / our code not something determined by AWS service teams
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The runtime & our code are determined by AWS specifications, hence the AWS
prefix suggestion.
Imo SDK
by itself would be ambiguous. By itself, it doesn't carry the meaning that it's built for AWS spec.
Come to think of it though, I guess making the prefix SDK
does allow users to easily distinguish SDK module imports vs Service module imports since all the service modules start with AWS
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used AWSSDK
as the prefix for SDK runtime modules because all our service client modules are prefixed with only AWS
.
For example, I can easily see an AWS service being launched with the name Identity
... you can see the potential for namespace collisions.
So using AWSSDK
as the prefix for runtime names helps to prevent namespace collisions between SDK components and AWS service clients.
import Foundation | ||
|
||
/// A credential identity resolver that caches the credentials sourced from the provided resolver. | ||
public struct CachedAWSCredentialIdentityResolver: AWSCredentialIdentityResolvedByCRT { | ||
let crtAWSCredentialIdentityResolver: AwsCommonRuntimeKit.CredentialsProvider | ||
public let crtAWSCredentialIdentityResolver: AwsCommonRuntimeKit.CredentialsProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Why was this property made public in this and other AWS credential identity resolvers? Afaik I don't think we want to expose the underlying CRT stuff where possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on keeping this private, if code outside needs to interact with this let's add own public methods for accomplishing that rather than utilizing it directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly I did not look at this closely; I added public
to get the code to compile.
This should be sorted out in #1382 along with the rest of the identity code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Issue #
#1384 (Modularize Event Streams)
#1385 (Modularize Event Streams Auth)
Description of changes
Event streams code has been modularized by either moving it to a new module in this SDK or moving it out to smithy-swift. Several other functions (HTTPAuth, checksums, etc.) have been partially modularized along with event streams & event streams auth.
AWSSDKEventStreamsAuth
module created for signing event streams with SigV4.AWSSDKIdentity
,AWSSDKHTTPAuth
were created to support event streams, but are not complete.New/existing dependencies impact assessment, if applicable
No new dependencies were added to this change.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.