-
Notifications
You must be signed in to change notification settings - Fork 196
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
Port customizable operation to orchestrator #2706
Port customizable operation to orchestrator #2706
Conversation
This commit adds two interceptors, `RequestMapInterceptor` and `RequestMutationInterceptor`, both of which will be used to implement `map_request` and `mutate_request` on `CustomizableOperation` in the orchestrator.
This commit adds `CustomizableOperation` to the orchestrator. It is constructed when the `customize` method is called on a fluent builder. Technically speaking, the `customize` method in the orchestrator can be a synchronous method, but is currently marked `async` due to the counterpart in the middleware.
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 good! Just some minor things.
...amazon/smithy/rust/codegen/client/smithy/generators/client/CustomizableOperationGenerator.kt
Outdated
Show resolved
Hide resolved
...software/amazon/smithy/rust/codegen/client/smithy/generators/client/FluentClientGenerator.kt
Outdated
Show resolved
Hide resolved
##[doc(hidden)] | ||
// TODO(enableNewSmithyRuntime): Remove `async` once we switch to orchestrator | ||
pub async fn customize_orchestrator(self) -> #{CustomizableOperation} { | ||
#{CustomizableOperation} { fluent_builder: self, config_override: None, interceptors: vec![] } |
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.
Will the initial config override be lost if I do something like the following?
client.some_operation()
.config_override(some_config)
.customize()
.await
.add_interceptor(some_interceptor)
.send()
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 question. The given snippet no longer complies after this PR, since there is no config_override
on a fluent builder anymore. config_override
is only accessible after you call .customize
. Besides regular parameters for an operation input, I wanted to shove everything that's related to configuring a single operation invocation under CustomizableOperation
. That being said, I'm curious to know what you think.
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.
Sounds good.
…egen/client/smithy/generators/client/CustomizableOperationGenerator.kt Co-authored-by: John DiSanti <jdisanti@amazon.com>
…egen/client/smithy/generators/client/FluentClientGenerator.kt Co-authored-by: John DiSanti <jdisanti@amazon.com>
A new generated diff is ready to view.
A new doc preview is ready to view. |
This commit addresses #2706 (comment) #2706 (comment)
…ttps://github.com/awslabs/smithy-rs into ysaito/port-customizable-operation-to-orchestrator
This commit makes the `customize` method in the orchestrator return a `Result` so its signature is fully compatible with the counterpart in the middleware.
A new generated diff is ready to view.
A new doc preview is ready to view. |
## Motivation and Context Port [Customizable Operation](#1647) to orchestrator ## Description This PR implements `CustomizableOperation` in the orchestrator. Just like the counterpart in the middleware, it is created when the `customize` method (in the orchestrator mode) on a fluent builder is called. The `customize` method in the orchestrator could technically be made a synchronous method because there is no need to create an operation, which requires `async`, therefore making the `customize` method in the middleware `async`. However, during the transition from the middleware to the orchestrator, the integration tests ([example](https://github.com/awslabs/smithy-rs/blob/31c152d9af53afb9a5e6edf9df3def57931b9c1e/aws/sdk/integration-tests/s3/tests/signing-it.rs#L36)) need to be able to run in both modes. For this reason, the `customize` method in the orchestrator is temporarily marked as `async`. Regarding methods defined on the new `CustomizableOperation`, they include `mutate_request` and `map_request` from the counterpart in the middleware. However, it did not port `map_operation` because there is no operation to map on. Most use cases for `map_operation` is put things in a property bag. The new `CustomizableOperation` provides an `interceptor` method to accomplish the same, i.e putting things in a config bag. Finally, for integration tests to run in both modes, the code gen emits the implementation of the `customize` method differently depending on the active Smithy runtime mode, similar to what the implementation of `send` method does. ## Testing Added one `sra-test` for mutating a request. ---- _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>
## Motivation and Context Port [Customizable Operation](#1647) to orchestrator ## Description This PR implements `CustomizableOperation` in the orchestrator. Just like the counterpart in the middleware, it is created when the `customize` method (in the orchestrator mode) on a fluent builder is called. The `customize` method in the orchestrator could technically be made a synchronous method because there is no need to create an operation, which requires `async`, therefore making the `customize` method in the middleware `async`. However, during the transition from the middleware to the orchestrator, the integration tests ([example](https://github.com/awslabs/smithy-rs/blob/31c152d9af53afb9a5e6edf9df3def57931b9c1e/aws/sdk/integration-tests/s3/tests/signing-it.rs#L36)) need to be able to run in both modes. For this reason, the `customize` method in the orchestrator is temporarily marked as `async`. Regarding methods defined on the new `CustomizableOperation`, they include `mutate_request` and `map_request` from the counterpart in the middleware. However, it did not port `map_operation` because there is no operation to map on. Most use cases for `map_operation` is put things in a property bag. The new `CustomizableOperation` provides an `interceptor` method to accomplish the same, i.e putting things in a config bag. Finally, for integration tests to run in both modes, the code gen emits the implementation of the `customize` method differently depending on the active Smithy runtime mode, similar to what the implementation of `send` method does. ## Testing Added one `sra-test` for mutating a request. ---- _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>
## Motivation and Context Port [Customizable Operation](#1647) to orchestrator ## Description This PR implements `CustomizableOperation` in the orchestrator. Just like the counterpart in the middleware, it is created when the `customize` method (in the orchestrator mode) on a fluent builder is called. The `customize` method in the orchestrator could technically be made a synchronous method because there is no need to create an operation, which requires `async`, therefore making the `customize` method in the middleware `async`. However, during the transition from the middleware to the orchestrator, the integration tests ([example](https://github.com/awslabs/smithy-rs/blob/31c152d9af53afb9a5e6edf9df3def57931b9c1e/aws/sdk/integration-tests/s3/tests/signing-it.rs#L36)) need to be able to run in both modes. For this reason, the `customize` method in the orchestrator is temporarily marked as `async`. Regarding methods defined on the new `CustomizableOperation`, they include `mutate_request` and `map_request` from the counterpart in the middleware. However, it did not port `map_operation` because there is no operation to map on. Most use cases for `map_operation` is put things in a property bag. The new `CustomizableOperation` provides an `interceptor` method to accomplish the same, i.e putting things in a config bag. Finally, for integration tests to run in both modes, the code gen emits the implementation of the `customize` method differently depending on the active Smithy runtime mode, similar to what the implementation of `send` method does. ## Testing Added one `sra-test` for mutating a request. ---- _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>
## Motivation and Context Render `CustomizableOperation` once in the `customizable` module instead of rendering it in every operation's `builders` module. ## Description This PR is a follow-up on #2706. The previous PR ported `CustomizableOperation` in the middleware to the orchestrator but it had a flaw in that the type was rendered per every operation. This was clearly a codegen regression because the code for `CustomizableOperation` is repeated many times and is rendered even if no customization is requested for an operation. This PR attempts to fix that problem. Just like `CustomizableOperation` in the middleware, we render the new `CustomizableOperation` once in the `customize` module per crate. To accomplish that, the new `CustomizableOperation` uses a closure, called `customizable_send`, to encapsulate a call to a fluent builder's `send` method and invokes it when its own `send` method is called. ~~As a side note, this PR will not take care of the following. We have [a separate PR](#2723) to fix them and once we've merged it to this PR, they should be addressed automatically (there will be merge conflicts, though):~~ - ~~Removing `send_orchestrator_with_plugin` (which is why a type parameter `R` is present in the code changes, but it'll soon go away)~~ - ~~Incorrect signature of a closure in orchestrator's `CustomizableOperaton::map_request`~~ ## Testing No new tests added as it's purely refactoring. Confirmed `sra-test` passed (except for the one that's known to fail). ---- _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>
Motivation and Context
Port Customizable Operation to orchestrator
Description
This PR implements
CustomizableOperation
in the orchestrator. Just like the counterpart in the middleware, it is created when thecustomize
method (in the orchestrator mode) on a fluent builder is called. Thecustomize
method in the orchestrator could technically be made a synchronous method because there is no need to create an operation, which requiresasync
, therefore making thecustomize
method in the middlewareasync
. However, during the transition from the middleware to the orchestrator, the integration tests (example) need to be able to run in both modes. For this reason, thecustomize
method in the orchestrator is temporarily marked asasync
.Regarding methods defined on the new
CustomizableOperation
, they includemutate_request
andmap_request
from the counterpart in the middleware. However, it did not portmap_operation
because there is no operation to map on. Most use cases formap_operation
is put things in a property bag. The newCustomizableOperation
provides aninterceptor
method to accomplish the same, i.e putting things in a config bag.Finally, for integration tests to run in both modes, the code gen emits the implementation of the
customize
method differently depending on the active Smithy runtime mode, similar to what the implementation ofsend
method does.Testing
Added one
sra-test
for mutating a request.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.