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

Clean up re-exports and improve 'BuildError' conversions #3173

Merged
merged 2 commits into from
Nov 10, 2023

Conversation

rcoh
Copy link
Collaborator

@rcoh rcoh commented Nov 10, 2023

Motivation and Context

Description

  • Add configReExport to make it easy and consistent to re-export types into the config module when they are used!
  • Add this for a bunch of types and clean up some (now) dead code
  • Re export BuildError
  • Enable converting from BuildError into SdkError

There are probably more places this can be used, but I'd like to keep this change small to facilitate easy backport to 0.57.

Testing

CI

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.

@rcoh rcoh added the needs-backport needs to be merged back into the main branch label Nov 10, 2023
@rcoh rcoh mentioned this pull request Nov 10, 2023
7 tasks
@rcoh rcoh requested review from jdisanti, Velfi and ysaito1001 and removed request for Velfi November 10, 2023 15:46
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 is awesome!

Comment on lines -93 to 92
use #{IntoShared};
#{StaticUriEndpointResolver}::uri(url).into_shared()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This compiles? How does it know where into_shared came from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's re-exported above

* Although it is not always possible to use this, this is the preferred method for using types in config customizations
* and ensures that your type will be re-exported if it is used.
*/
fun configReexport(type: RuntimeType): RuntimeType = RuntimeType.forInlineFun(type.name, module = ClientRustModule.config) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

In an ideal world, I prefer to have all the re-exports in one place, but I understand the need to make them conditional and how that's easier with this approach. That said, I don't think we should use this for re-exports that are supposed to always be present since then it could be easy to break one of these re-exports just by changing codegen in some other place.

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 see that but I think:

  1. It's easier to miss items
  2. We'll get a semver failure if we delete something by accident

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The other benefit is that in-situ, we're actually using the rexport which I think is a benefit. We could make non-conditional re-exports be runtime types though, not opposed to that.

@rcoh rcoh requested review from a team as code owners November 10, 2023 19:46
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@rcoh rcoh added this pull request to the merge queue Nov 10, 2023
Merged via the queue into main with commit acbe8ce Nov 10, 2023
41 checks passed
@rcoh rcoh deleted the config-re-exports-cleanup branch November 10, 2023 21:51
rcoh added a commit that referenced this pull request Nov 13, 2023
## Motivation and Context
- Fixes #3171 
- Fixes #3155 
- Fixes #3172 


## Description
- Add `configReExport` to make it easy and consistent to re-export types
into the config module when they are used!
- Add this for a bunch of types and clean up some (now) dead code
- Re export `BuildError`
- Enable converting from `BuildError` into `SdkError`

There are probably more places this can be used, but I'd like to keep
this change small to facilitate easy backport to 0.57.

## Testing
CI

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [x] 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._
rcoh added a commit that referenced this pull request Nov 13, 2023
## Motivation and Context
- Fixes #3171 
- Fixes #3155 
- Fixes #3172 


## Description
- Add `configReExport` to make it easy and consistent to re-export types
into the config module when they are used!
- Add this for a bunch of types and clean up some (now) dead code
- Re export `BuildError`
- Enable converting from `BuildError` into `SdkError`

There are probably more places this can be used, but I'd like to keep
this change small to facilitate easy backport to 0.57.

## Testing
CI

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [x] 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._
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-backport needs to be merged back into the main branch
Projects
None yet
3 participants