-
Notifications
You must be signed in to change notification settings - Fork 182
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
RFC: Customizable client operations #1545
Conversation
|
||
impl<O, R> CustomizableOperation<O, R> { | ||
// Allows for customizing the operation's request | ||
fn map_request<E>( |
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 could also add mutate_request
for the common case where we don't need to take ownership and the changes are infallible
fn mutate_request(self, f: impl FnOnce(&mut Request<SdkBody)) -> Self { ... }
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 idea!
### Eliminating `async` from `make_operation` | ||
|
||
To avoid requiring an `await` after the call to `customize`, the `make_operation` function | ||
generated on input structs needs to be made synchronous. The `make_operation` function | ||
originally was synchronous, but was made async during the implementation of the Glacier |
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 think I'd probaby keep it async and require an await after customize. I think keeping make_operation async is fairly important from the perspective of keeping the design forwards compatible
A new generated diff is ready to view.
A new doc preview is ready to view. |
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
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.
LGTM...galaxy brain thought: with this change can we make make_operation
private...?
I think not quite because of how we use STS in credentials
A new generated diff is ready to view.
A new doc preview is ready to view. |
} | ||
|
||
// Convenience for `map_request` where infallible direct mutation of request is acceptable | ||
fn mutate_request<E>( |
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 function doesn't use the type parameter which was declared.
I think this is causing me to be unable to compile due to
154 | .mutate_request(|req| {
| ^^^^^^^^^^^^^^ cannot infer type for type parameter `E` declared on the associated function `mutate_request`
code:
.mutate_request(|req| {
if let Some(request_id) = request_id {
req.headers_mut().insert(
HeaderName::from_static("x-amzn-requestid"),
HeaderValue::from_static(request_id),
);
}
})
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 was fixed in #1835, which will be included in the next SDK release.
Motivation and Context
This RFC refines a solution that was briefly outlined in awslabs/aws-sdk-rust#537 to the problem of easily customizing the HTTP requests that the SDK will make.
Rendered view
Shout out to @rcoh and @Velfi for all the ideas on how we could approach this!
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.