-
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.
Allows configuration of interceptors on a client level by adding interceptor providers to client config, allowing Plugins to add interceptors. The primary addition is `InterceptorProvider`, an interface that creates generic interceptors which can operate on any transport - http or otherwise. When an operation is executed, interceptor providers are called to create new instances of service-level interceptors. Creating new instances also means we don't need to synchronize on the shared interceptors. Transport specific config, have their own methods for adding interceptor providers, so you can add `HttpInterceptorProvider`s to http config. Operations know which transport they operate on, and can choose which transport-specific interceptor providers to use. If/when we have operation-level configuration, it might make more sense to allow plugins to configure more generic 'operation customizations' or something, rather than just the interceptors. Operations would then call the customizations before executing. A few other minor changes were made to the client libraries: - Removed HasAttributes protocol and corresponding AttributesType from interceptor interfaces, as we now just use `Context`. - Changed InterceptorContext `getResult` to `getOutput`. We still store a `Result<OutputType, Error>` in DefaultInterceptorContext, but `getOutput` now throws that error if it is present, otherwise just returns `OutputType` - Added actual builder methods to RequestMessageBuilder, which we would need eventually, so I could use them in testing - Made SdkHttpRequestBuilder final Codegen was also updated to generate the new config methods, and to call interceptor providers in operations to add configured interceptors.
- Loading branch information
1 parent
27a3724
commit bdbfa0b
Showing
49 changed files
with
617 additions
and
355 deletions.
There are no files selected for viewing
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
20 changes: 0 additions & 20 deletions
20
Sources/ClientRuntime/Interceptor/HasAttributes+Logger.swift
This file was deleted.
Oops, something went wrong.
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
17 changes: 17 additions & 0 deletions
17
Sources/ClientRuntime/Interceptor/HttpInterceptorProvider.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 | ||
// | ||
|
||
/// Provides implementations of `HttpInterceptor`. | ||
/// | ||
/// For the generic counterpart, see `InterceptorProvider`. | ||
public protocol HttpInterceptorProvider { | ||
|
||
/// Creates an instance of an `HttpInterceptor` implementation. | ||
/// | ||
/// - Returns: The `HttpInterceptor` implementation. | ||
func create<InputType, OutputType>() -> any HttpInterceptor<InputType, OutputType> | ||
} |
Oops, something went wrong.