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

Refactor endpoints to be Smithy-native #1641

Merged
merged 8 commits into from
Aug 23, 2022
Merged

Refactor endpoints to be Smithy-native #1641

merged 8 commits into from
Aug 23, 2022

Conversation

rcoh
Copy link
Collaborator

@rcoh rcoh commented Aug 17, 2022

Motivation and Context

Description

This makes a 99% backwards compatible refactoring to:

  1. Create the aws_smithy_types::Endpoint type
  2. Create the aws_smithy_http::endpoint::ResolveEndpoint trait (tbd: this may move into aws_smithy_types)
  3. Use ResolveEndpoint inside of <service>::Config internally instead of ResolveAwsEndpoint
  4. Shim ResolveAwsEndpoint against ResolveEndpoint via a static Params struct (in the future, this will be code generated per-service).
  5. Update the make_operation to write the endpoint into the bag instead of writing the endpoint resolver into the bag & update the AWS middleware accordingly

Testing

  • UT/IT
  • canary

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the smithy-rs codegen or runtime crates
  • I have updated CHANGELOG.next.toml if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@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.

@rcoh rcoh force-pushed the endpoints-refactor-part-1 branch from 8836d0b to 9a5fa97 Compare August 17, 2022 20:05
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@rcoh rcoh force-pushed the endpoints-refactor-part-1 branch from 9a5fa97 to 543ecae Compare August 18, 2022 13:19
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@rcoh rcoh force-pushed the endpoints-refactor-part-1 branch from 543ecae to 76385ae Compare August 18, 2022 15:44
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@rcoh rcoh marked this pull request as ready for review August 18, 2022 17:23
@rcoh rcoh requested a review from a team as a code owner August 18, 2022 17:23
let aws_endpoint = self
.0
.resolve_endpoint(params.region.as_ref().unwrap_or(
/*EndpointError::message("no region in params")*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Leftover comment?

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 catch, fixed

Comment on lines 130 to 133
// unwrap safety: we just put it in the bag, we can take it out again.
let endpoint = props
.get::<aws_smithy_http::endpoint::Result>()
.map(|res|res.as_ref().unwrap()).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is leaving a comment like this preferable to using .expect()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did a cleaner version of this where I just replace the error with a leftover error

@rcoh rcoh force-pushed the endpoints-refactor-part-1 branch from 76385ae to e0a4a7e Compare August 19, 2022 16:12
@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

@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.

LGTM!

@@ -48,6 +92,28 @@ pub enum InvalidEndpoint {
EndpointMustHaveAuthority,
}

pub fn apply_endpoint(uri: &mut Uri, endpoint: &Uri, prefix: Option<&EndpointPrefix>) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Needs documentation

Comment on lines 123 to 125
if self.endpoint.url() == "" {
panic!("URL was unset");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if self.endpoint.url() == "" {
panic!("URL was unset");
}
assert!(self.endpoint.url() != "", "URL was unset");

@rcoh rcoh enabled auto-merge (squash) August 23, 2022 16:10
@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.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@rcoh rcoh merged commit fc1e179 into main Aug 23, 2022
@rcoh rcoh deleted the endpoints-refactor-part-1 branch August 23, 2022 19:19
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