Skip to content
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

Merged
merged 28 commits into from
May 12, 2023

Conversation

ysaito1001
Copy link
Contributor

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.

ysaito1001 and others added 21 commits May 3, 2023 09:57
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>
This commit addresses the following discussions:
#2669 (comment)
#2669 (comment)
@ysaito1001 ysaito1001 requested a review from a team as a code owner May 12, 2023 02:59
@@ -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"))]
Copy link
Contributor Author

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.

Copy link
Collaborator

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.

@github-actions
Copy link

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

Copy link
Collaborator

@jdisanti jdisanti left a 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.

@ysaito1001 ysaito1001 enabled auto-merge May 12, 2023 17:53
@ysaito1001 ysaito1001 added this pull request to the merge queue May 12, 2023
@github-actions
Copy link

A new generated diff is ready to view.

  • AWS SDK (ignoring whitespace)
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

Merged via the queue into main with commit 92b26df May 12, 2023
@ysaito1001 ysaito1001 deleted the ysaito/configure-interceptors-on-generic-client branch May 12, 2023 18:37
david-perez pushed a commit that referenced this pull request May 18, 2023
## 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>
david-perez pushed a commit that referenced this pull request May 22, 2023
## 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>
david-perez pushed a commit that referenced this pull request May 22, 2023
## 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants