-
Notifications
You must be signed in to change notification settings - Fork 196
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
Use the orchestrator client for ECS and IMDS credentials in aws-config #2997
Conversation
This ports the direct uses of the `aws_smithy_client::Client` in aws_config to the orchestrator.
3281229
to
3b4be07
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
the direct changes look good. My main questions / feedback are around the explicit |
aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/AwsPresigningDecorator.kt
Outdated
Show resolved
Hide resolved
...are/amazon/smithy/rust/codegen/client/smithy/customizations/HttpChecksumRequiredGenerator.kt
Outdated
Show resolved
Hide resolved
...oftware/amazon/smithy/rust/codegen/client/smithy/customizations/IdempotencyTokenGenerator.kt
Outdated
Show resolved
Hide resolved
rust-runtime/aws-smithy-runtime-api/src/client/runtime_plugin.rs
Outdated
Show resolved
Hide resolved
rust-runtime/aws-smithy-runtime-api/src/client/runtime_plugin.rs
Outdated
Show resolved
Hide resolved
A new generated diff is ready to view.
A new doc preview 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.
I like IntoShared! We should probably ensure that you get decent type hints / docs in various editors at some point
pub trait IntoShared<Shared> { | ||
/// Creates a shared type from an unshared type. | ||
fn into_shared(self) -> Shared; | ||
} |
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 think this should be an associated type? It doesn't make sense for one type to be convertible into multiple different shared types right?
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 basically made these traits equivalent to From
/Into
. I guess it makes sense to restrict it to one shared type, but typing IntoShared<Shared = MySharedType>
everywhere kind of sucks. I wish we had trait aliases.
/// ```rust,no_run | ||
/// use aws_smithy_runtime_api::impl_shared_conversions; | ||
/// use std::sync::Arc; | ||
/// | ||
/// trait Thing {} | ||
/// | ||
/// struct Thingamajig; | ||
/// impl Thing for Thingamajig {} | ||
/// | ||
/// struct SharedThing(Arc<dyn Thing>); | ||
/// impl Thing for SharedThing {} | ||
/// impl SharedThing { | ||
/// fn new(thing: impl Thing + 'static) -> Self { | ||
/// Self(Arc::new(thing)) | ||
/// } | ||
/// } | ||
/// impl_shared_conversions!(convert SharedThing from Thing using SharedThing::new); | ||
/// ``` |
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.
thanks for adding an example!
#[test] | ||
fn test() { | ||
let thing = Thingamajig; | ||
assert_eq!("Thingamajig", format!("{thing:?}"), "precondition"); | ||
|
||
let shared_thing: SharedThing = thing.into_shared(); | ||
assert_eq!( | ||
"SharedThing(Thingamajig)", | ||
format!("{shared_thing:?}"), | ||
"precondition" | ||
); | ||
|
||
let very_shared_thing: SharedThing = shared_thing.into_shared(); | ||
assert_eq!( | ||
"SharedThing(Thingamajig)", | ||
format!("{very_shared_thing:?}"), | ||
"it should not nest the shared thing in another shared thing" | ||
); | ||
} |
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.
should we assert via downcasting that an already shared type is not double boxed?
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.
This seems to be very non-trivial.
.with_endpoint_resolver(Some(FakeEndpointResolver)) | ||
.with_http_connector(Some(FakeConnector)) |
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.
should these methods accept T
instead of Option<T>
? I might imagine a set_
that accepted an option 💭
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.
It already has the the set_
variants. I can't remember why I did it this way, but it looks like nothing is calling them with None
. So I think this is a sane change to make.
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.
Thinking this should be done in a follow-up PR.
impl AsRef<dyn Interceptor> for SharedInterceptor { | ||
fn as_ref(&self) -> &(dyn Interceptor + 'static) { | ||
self.interceptor.as_ref() |
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.
any reason to remove this? seems like a reasonable way to handle it
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 can't use the IntoShared
/FromUnshared
traits with it if it is done this way. We might just want to code generate the Interceptor and SharedInterceptor types, come to think of it. They're just not fun to work with in Rust due to the insane number of similar looking hooks with a ton of arguments.
impl_shared_conversions!( | ||
convert SharedAuthSchemeOptionResolver | ||
from AuthSchemeOptionResolver | ||
using SharedAuthSchemeOptionResolver::new | ||
); |
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'd probably consider adding :
in the macro to remove any parsing hazard but this seems to be working fine
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.
convert: SharedAuthSchemeOptionResolver
from: Auth....
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
This ports the direct uses of the
aws_smithy_client::Client
in aws_config to the orchestrator.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.