Skip to content

Commit

Permalink
feat: finish interceptors migration
Browse files Browse the repository at this point in the history
Removes all Middleware types, references, and implementations, completing
migration to using Orchestrator + Interceptors. Tests using middleware
were also migrated to use Orchestrator + Interceptors. Codegen was updated,
removing the `useInterceptors` setting, switching all code that was either
generating middleware or interceptors to just generate interceptors. This
also allowed removing some other existing generator code around middleware
steps.

As with the corresponding aws-sdk-swift commit, this is already a large commit
so I wanted to avoid doing too much refactoring or moving code around. For
example, I didn't change file names or type names. There's probably a good
deal of refactoring that can be done, but it is out of scope for this PR.

Also, this commit removes the amz-sdk-invocation-id/amz-sdk-request header impl
as it was moved to aws-sdk-swift in the corresponding commit.
  • Loading branch information
milesziemer committed Jul 18, 2024
1 parent e949da7 commit 5529c8e
Show file tree
Hide file tree
Showing 113 changed files with 470 additions and 2,574 deletions.
19 changes: 1 addition & 18 deletions Sources/ClientRuntime/Endpoints/EndpointResolverMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import struct SmithyHTTPAuthAPI.SelectedAuthScheme
import enum SmithyHTTPAuthAPI.SigningAlgorithm
import enum SmithyHTTPAuthAPI.SigningPropertyKeys

public struct EndpointResolverMiddleware<OperationStackOutput, Params: EndpointsRequestContextProviding>: Middleware {
public struct EndpointResolverMiddleware<OperationStackOutput, Params: EndpointsRequestContextProviding> {
public let id: Swift.String = "EndpointResolverMiddleware"

let endpointResolverBlock: (Params) throws -> Endpoint
Expand All @@ -31,23 +31,6 @@ public struct EndpointResolverMiddleware<OperationStackOutput, Params: Endpoints
self.endpointParams = endpointParams
self.authSchemeResolver = authSchemeResolver
}

public func handle<H>(
context: Smithy.Context,
input: HTTPRequestBuilder,
next: H
) async throws -> OperationOutput<OperationStackOutput>
where H: Handler,
Self.MInput == H.Input,
Self.MOutput == H.Output {
let selectedAuthScheme = context.selectedAuthScheme
let request = input.build()
let updatedRequest =
try await apply(request: request, selectedAuthScheme: selectedAuthScheme, attributes: context)
return try await next.handle(context: context, input: updatedRequest.toBuilder())
}
public typealias MInput = HTTPRequestBuilder
public typealias MOutput = OperationOutput<OperationStackOutput>
}

extension EndpointResolverMiddleware: ApplyEndpoint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,14 @@

import class Smithy.Context

public struct IdempotencyTokenMiddleware<OperationStackInput, OperationStackOutput>: Middleware {
public struct IdempotencyTokenMiddleware<OperationStackInput, OperationStackOutput> {
public let id: Swift.String = "IdempotencyTokenMiddleware"
private let keyPath: WritableKeyPath<OperationStackInput, String?>

public init(keyPath: WritableKeyPath<OperationStackInput, String?>) {
self.keyPath = keyPath
}

public func handle<H>(context: Smithy.Context,
input: MInput,
next: H) async throws -> MOutput
where H: Handler, Self.MInput == H.Input, Self.MOutput == H.Output {
let withToken = addToken(input: input, attributes: context)
return try await next.handle(context: context, input: withToken)
}

private func addToken(input: OperationStackInput, attributes: Smithy.Context) -> OperationStackInput {
var copiedInput = input
if input[keyPath: keyPath] == nil {
Expand All @@ -31,10 +23,6 @@ public struct IdempotencyTokenMiddleware<OperationStackInput, OperationStackOutp
}
return copiedInput
}

public typealias MInput = OperationStackInput
public typealias MOutput = OperationOutput<OperationStackOutput>
public typealias Context = Smithy.Context
}

extension IdempotencyTokenMiddleware: HttpInterceptor {
Expand Down
26 changes: 0 additions & 26 deletions Sources/ClientRuntime/Middleware/AnyHandler.swift

This file was deleted.

42 changes: 0 additions & 42 deletions Sources/ClientRuntime/Middleware/AnyMiddleware.swift

This file was deleted.

33 changes: 0 additions & 33 deletions Sources/ClientRuntime/Middleware/ComposedHandler.swift

This file was deleted.

21 changes: 0 additions & 21 deletions Sources/ClientRuntime/Middleware/Handler.swift

This file was deleted.

12 changes: 0 additions & 12 deletions Sources/ClientRuntime/Middleware/HandlerFunction.swift

This file was deleted.

24 changes: 0 additions & 24 deletions Sources/ClientRuntime/Middleware/Middleware.swift

This file was deleted.

11 changes: 0 additions & 11 deletions Sources/ClientRuntime/Middleware/MiddlewareFunction.swift

This file was deleted.

69 changes: 0 additions & 69 deletions Sources/ClientRuntime/Middleware/MiddlewareStep.swift

This file was deleted.

21 changes: 0 additions & 21 deletions Sources/ClientRuntime/Middleware/NoopHandler.swift

This file was deleted.

Loading

0 comments on commit 5529c8e

Please sign in to comment.