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

RFC: Customizable client operations #1545

Merged
merged 6 commits into from
Jul 18, 2022
Merged

RFC: Customizable client operations #1545

merged 6 commits into from
Jul 18, 2022

Conversation

jdisanti
Copy link
Collaborator

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.


impl<O, R> CustomizableOperation<O, R> {
// Allows for customizing the operation's request
fn map_request<E>(
Copy link
Collaborator

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 { ... }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

Comment on lines 141 to 145
### 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
Copy link
Collaborator

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

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link
Collaborator

@rcoh rcoh left a 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

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@jdisanti jdisanti merged commit e4d8dca into main Jul 18, 2022
@jdisanti jdisanti deleted the jdisanti-rfc-cust-op branch July 18, 2022 23:46
}

// Convenience for `map_request` where infallible direct mutation of request is acceptable
fn mutate_request<E>(
Copy link
Contributor

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),
                    );
                }
            })

Copy link
Collaborator Author

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.

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.

None yet

4 participants