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

Use the orchestrator client for ECS and IMDS credentials in aws-config #2997

Merged
merged 13 commits into from
Sep 29, 2023

Conversation

jdisanti
Copy link
Collaborator

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.

This ports the direct uses of the `aws_smithy_client::Client` in
aws_config to the orchestrator.
@jdisanti jdisanti force-pushed the jdisanti-aws-config-direct-invoke branch from 3281229 to 3b4be07 Compare September 23, 2023 00:53
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@jdisanti jdisanti added the breaking-change This will require a breaking change label Sep 25, 2023
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@jdisanti jdisanti marked this pull request as ready for review September 25, 2023 18:54
@jdisanti jdisanti requested review from a team as code owners September 25, 2023 18:54
@rcoh
Copy link
Collaborator

rcoh commented Sep 26, 2023

the direct changes look good. My main questions / feedback are around the explicit SharedRuntimePlugin API change.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview 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.

I like IntoShared! We should probably ensure that you get decent type hints / docs in various editors at some point

Comment on lines +25 to +28
pub trait IntoShared<Shared> {
/// Creates a shared type from an unshared type.
fn into_shared(self) -> Shared;
}
Copy link
Collaborator

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?

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

Comment on lines +64 to +81
/// ```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);
/// ```
Copy link
Collaborator

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!

Comment on lines +118 to +136
#[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"
);
}
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Comment on lines +644 to +645
.with_endpoint_resolver(Some(FakeEndpointResolver))
.with_http_connector(Some(FakeConnector))
Copy link
Collaborator

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 💭

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

Copy link
Collaborator Author

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.

Comment on lines -621 to -623
impl AsRef<dyn Interceptor> for SharedInterceptor {
fn as_ref(&self) -> &(dyn Interceptor + 'static) {
self.interceptor.as_ref()
Copy link
Collaborator

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

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

Comment on lines +124 to +128
impl_shared_conversions!(
convert SharedAuthSchemeOptionResolver
from AuthSchemeOptionResolver
using SharedAuthSchemeOptionResolver::new
);
Copy link
Collaborator

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

convert: SharedAuthSchemeOptionResolver
from: Auth....

aws/rust-runtime/aws-config/src/imds/client/token.rs Outdated Show resolved Hide resolved
aws/rust-runtime/aws-config/src/imds/client/token.rs Outdated Show resolved Hide resolved
@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.

@jdisanti jdisanti added this pull request to the merge queue Sep 29, 2023
Merged via the queue into main with commit d800d33 Sep 29, 2023
40 of 41 checks passed
@jdisanti jdisanti deleted the jdisanti-aws-config-direct-invoke branch September 29, 2023 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This will require a breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants