-
Notifications
You must be signed in to change notification settings - Fork 190
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
Conversation
A new doc preview is ready to view. |
A new generated diff is ready to view.
|
A new doc preview is ready to view. |
A new generated diff 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!
/// 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()), | ||
)) |
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 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)
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.
Filed an issue for improving these docs overall: awslabs/aws-sdk-rust#469
A new generated diff is ready to view.
|
A new doc preview is ready to view. |
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
andnative_tls_static
equivalents for static dispatch, but I thought those might cause confusion.Testing
Checklist
CHANGELOG.next.toml
if I made changes to the smithy-rs codegen or runtime cratesCHANGELOG.next.toml
if I made changes to the AWS SDK, generated SDK code, or SDK runtime cratesBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.