-
Notifications
You must be signed in to change notification settings - Fork 187
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
Allow for configuring interceptors on generic client #2697
Allow for configuring interceptors on generic client #2697
Conversation
This commit adds newtypes `SharedInterceptor` and `AddOnlyInterceptors` around existing types so that they can be used outside of their defining crates without revealing the implementation details.
This commit allows users to pass their own interceptors to `ConfigLoader` and to `SdkConfig`. The docs for their methods are marked as `#[doc(hidden)]` until the orchestrator is fully functional.
This commit updates the codegen to register user-passed-in interceptors. Registration takes place at the client config level and the operation config level. The former is handled in `ServiceRuntimePlugin` and the latter in service config `Builder`.
This commit updates `sra_test` to verify interceptors can be configured at the client config level. It also adds a test to ensure interceptors registered run according to the pre-defined priority.
Co-authored-by: John DiSanti <jdisanti@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
Co-authored-by: John DiSanti <jdisanti@amazon.com>
…egen/client/smithy/customizations/InterceptorConfigCustomization.kt Co-authored-by: John DiSanti <jdisanti@amazon.com>
…egen/client/smithy/customizations/InterceptorConfigCustomization.kt Co-authored-by: John DiSanti <jdisanti@amazon.com>
…egen/client/smithy/generators/config/ServiceConfigGenerator.kt Co-authored-by: John DiSanti <jdisanti@amazon.com>
…ps://github.com/awslabs/smithy-rs into ysaito/configure-interceptors-at-various-levels
This commit addresses #2669 (comment)
This commit addresses #2669 (comment)
This commit addresses the following discussions: #2669 (comment) #2669 (comment)
This commit addresses the following discussions: #2669 (comment) #2669 (comment)
This commit addresses #2669 (comment)
@@ -216,7 +216,7 @@ async fn make_an_attempt( | |||
Ok(checkpoint) | |||
} | |||
|
|||
#[cfg(all(test, feature = "test-util"))] | |||
#[cfg(all(test, feature = "test-util", feature = "anonymous-auth"))] |
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.
We may want to move what's in anonymous_auth
to test-util
if it's meant to be used only for testing, but that should probably be discussed & handled in a separate PR if needed. We just specify anonymous-auth
here to unblock this PR.
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 don't think it's just for testing, but I'm not 100% on that yet. The question will be: is the absence of an auth scheme/option automatically anonymous, or should we keep this thing around? Probably the former so that a model can explicitly say that an operation doesn't require auth. However, I don't think Smithy has any way to communicate that currently.
A new generated diff is ready to view.
A new doc preview is ready to view. |
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 looks great! Just some minor comments.
aws/sra-test/integration-tests/aws-sdk-s3/tests/interceptors.rs
Outdated
Show resolved
Hide resolved
...re/amazon/smithy/rust/codegen/client/smithy/customizations/InterceptorConfigCustomization.kt
Outdated
Show resolved
Hide resolved
...tware/amazon/smithy/rust/codegen/client/smithy/generators/OperationRuntimePluginGenerator.kt
Outdated
Show resolved
Hide resolved
...oftware/amazon/smithy/rust/codegen/client/smithy/generators/ServiceRuntimePluginGenerator.kt
Outdated
Show resolved
Hide resolved
This commit addresses #2697 (comment)
This commit addresses #2697 (comment)
This commit addresses #2697 (comment)
This commit incorporates feedback #2697 (comment)
A new generated diff is ready to view.
A new doc preview is ready to view. |
## Description This PR allows users to pass-in interceptors to a generic client. Client-level configured interceptors are eventually added to `client_interceptors` and operation-level interceptors to `operation_interceptors`, both of which are fields in the `aws-smithy-runtime-api::client::interceptors::Interceptors`. The relevant code is generated only in the orchestrator mode. The SDK registers a default set of (client-level & operation-level) interceptors, and the passed-in interceptors by a user will run _after_ those default interceptors. ## Testing - Added integration tests `operation_interceptor_test` and `interceptor_priority` in `sra_test`. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: Yuki Saito <awsaito@amazon.com> Co-authored-by: John DiSanti <jdisanti@amazon.com>
## Description This PR allows users to pass-in interceptors to a generic client. Client-level configured interceptors are eventually added to `client_interceptors` and operation-level interceptors to `operation_interceptors`, both of which are fields in the `aws-smithy-runtime-api::client::interceptors::Interceptors`. The relevant code is generated only in the orchestrator mode. The SDK registers a default set of (client-level & operation-level) interceptors, and the passed-in interceptors by a user will run _after_ those default interceptors. ## Testing - Added integration tests `operation_interceptor_test` and `interceptor_priority` in `sra_test`. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: Yuki Saito <awsaito@amazon.com> Co-authored-by: John DiSanti <jdisanti@amazon.com>
## Description This PR allows users to pass-in interceptors to a generic client. Client-level configured interceptors are eventually added to `client_interceptors` and operation-level interceptors to `operation_interceptors`, both of which are fields in the `aws-smithy-runtime-api::client::interceptors::Interceptors`. The relevant code is generated only in the orchestrator mode. The SDK registers a default set of (client-level & operation-level) interceptors, and the passed-in interceptors by a user will run _after_ those default interceptors. ## Testing - Added integration tests `operation_interceptor_test` and `interceptor_priority` in `sra_test`. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: Yuki Saito <awsaito@amazon.com> Co-authored-by: John DiSanti <jdisanti@amazon.com>
Description
This PR allows users to pass-in interceptors to a generic client. Client-level configured interceptors are eventually added to
client_interceptors
and operation-level interceptors tooperation_interceptors
, both of which are fields in theaws-smithy-runtime-api::client::interceptors::Interceptors
. The relevant code is generated only in the orchestrator mode.The SDK registers a default set of (client-level & operation-level) interceptors, and the passed-in interceptors by a user will run after those default interceptors.
Testing
operation_interceptor_test
andinterceptor_priority
insra_test
.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.