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 it possible to nest runtime components #2909

Merged
merged 3 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.next.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ references = ["smithy-rs#2904"]
meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client" }
author = "jdisanti"

[[smithy-rs]]
message = "It's now possible to nest runtime components with the `RuntimePlugin` trait. A `current_components` argument was added to the `runtime_components` method so that components configured from previous runtime plugins can be referenced in the current runtime plugin. Ordering of runtime plugins was also introduced via a new `RuntimePlugin::order` method."
references = ["smithy-rs#2909"]
meta = { "breaking" = true, "tada" = false, "bug" = false, "target" = "client"}
author = "jdisanti"

[[smithy-rs]]
message = "Fix incorrect summary docs for builders"
references = ["smithy-rs#2914", "aws-sdk-rust#825"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ impl RuntimePlugin for SigV4PresigningRuntimePlugin {
Some(layer.freeze())
}

fn runtime_components(&self) -> Cow<'_, RuntimeComponentsBuilder> {
fn runtime_components(
&self,
_: &RuntimeComponentsBuilder,
) -> Cow<'_, RuntimeComponentsBuilder> {
Cow::Borrowed(&self.runtime_components)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ConfigOverrideRuntimePluginGenerator(
Some(self.config.clone())
}

fn runtime_components(&self) -> #{Cow}<'_, #{RuntimeComponentsBuilder}> {
fn runtime_components(&self, _: &#{RuntimeComponentsBuilder}) -> #{Cow}<'_, #{RuntimeComponentsBuilder}> {
#{Cow}::Borrowed(&self.components)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class OperationRuntimePluginGenerator(
#{Some}(cfg.freeze())
}

fn runtime_components(&self) -> #{Cow}<'_, #{RuntimeComponentsBuilder}> {
fn runtime_components(&self, _: &#{RuntimeComponentsBuilder}) -> #{Cow}<'_, #{RuntimeComponentsBuilder}> {
// Retry classifiers are operation-specific because they need to downcast operation-specific error types.
let retry_classifiers = #{RetryClassifiers}::new()
#{retry_classifier_customizations};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class ServiceRuntimePluginGenerator(
self.config.clone()
}

fn runtime_components(&self) -> #{Cow}<'_, #{RuntimeComponentsBuilder}> {
fn runtime_components(&self, _: &#{RuntimeComponentsBuilder}) -> #{Cow}<'_, #{RuntimeComponentsBuilder}> {
#{Cow}::Borrowed(&self.runtime_components)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ internal class ConfigOverrideRuntimePluginGeneratorTest {
"EndpointResolverParams" to RuntimeType.smithyRuntimeApi(runtimeConfig)
.resolve("client::endpoint::EndpointResolverParams"),
"RuntimePlugin" to RuntimeType.runtimePlugin(runtimeConfig),
"RuntimeComponentsBuilder" to RuntimeType.runtimeComponentsBuilder(runtimeConfig),
)
rustCrate.testModule {
addDependency(CargoDependency.Tokio.toDevDependency().withFeature("test-util"))
Expand All @@ -67,7 +68,8 @@ internal class ConfigOverrideRuntimePluginGeneratorTest {
client_config.config,
&client_config.runtime_components,
);
let sut_components = sut.runtime_components();
let prev = #{RuntimeComponentsBuilder}::new("prev");
let sut_components = sut.runtime_components(&prev);
let endpoint_resolver = sut_components.endpoint_resolver().unwrap();
let endpoint = endpoint_resolver
.resolve_endpoint(&#{EndpointResolverParams}::new(crate::config::endpoint::Params {}))
Expand Down
3 changes: 3 additions & 0 deletions rust-runtime/aws-smithy-runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ tokio = { version = "1.25", features = ["sync"] }
tracing = "0.1"
zeroize = { version = "1", optional = true }

[dev-dependencies]
tokio = { version = "1.25", features = ["rt", "macros"] }

[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
Expand Down
Loading