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

Make rustls and native_tls client builder helpers dyn #1217

Merged
merged 3 commits into from
Feb 23, 2022

Conversation

jdisanti
Copy link
Collaborator

@jdisanti jdisanti commented Feb 23, 2022

Motivation and Context

This PR fixes awslabs/aws-sdk-rust#467 which was caused by making the SDK clients use DynConnector in #1132.

There's a bit of conflict here between smithy-rs and SDK use-cases. Developers using smithy-rs want the flexibility to use static dispatch on the client's connector, but the SDK does not need this. I'm opting to make the SDK use-case easy and convenient, and it should even work for most smithy-rs use-cases. Those who need to use static dispatch will need to manually construct an adapter (for example, builder.connector(Adapter::builder().build(aws_smithy_client::conns::https()))) if the performance difference is a concern.

I considered adding rustls_static and native_tls_static equivalents for static dispatch, but I thought those might cause confusion.

Testing

  • Added a test to check the return types

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.

@jdisanti jdisanti requested a review from a team as a code owner February 23, 2022 02:16
@github-actions
Copy link

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

@github-actions
Copy link

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff 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!

Comment on lines +307 to +322
/// Connect to the service over HTTPS using Rustls using dynamic dispatch.
pub fn rustls(self) -> ClientBuilder<DynConnector, M, R> {
self.connector(DynConnector::new(
Adapter::builder().build(crate::conns::https()),
))
}
}

#[cfg(feature = "native-tls")]
impl<M, R> ClientBuilder<(), M, R> {
/// Connect to the service over HTTPS using the native TLS library on your platform.
pub fn native_tls(
self,
) -> ClientBuilder<Adapter<hyper_tls::HttpsConnector<hyper::client::HttpConnector>>, M, R> {
self.connector(Adapter::builder().build(crate::conns::native_tls()))
/// Connect to the service over HTTPS using the native TLS library on your
/// platform using dynamic dispatch.
pub fn native_tls(self) -> ClientBuilder<DynConnector, M, R> {
self.connector(DynConnector::new(
Adapter::builder().build(crate::conns::native_tls()),
))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should examples in these methods about how not to use them when required (basically including examples of custom HTTPS, or at least linking to them)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Filed an issue for improving these docs overall: awslabs/aws-sdk-rust#469

@github-actions
Copy link

A new generated diff is ready to view.

@github-actions
Copy link

A new doc preview is ready to view.

@jdisanti jdisanti merged commit 8018080 into main Feb 23, 2022
@jdisanti jdisanti deleted the jdisanti-fix-client-builders branch February 23, 2022 18:58
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.

aws_sdk_dynamodb::client::Builder::new().rustls() no longer work as of v0.7.0
2 participants