Unverified Commit 67830dcc authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Make it possible to nest runtime components (#2909)

Runtime plugins need to be able to wrap components configured in other
runtime components. For example, one runtime plugin should be able to
wrap the HTTP connector configured in another runtime plugin.

This PR makes this possible by:
- Introducing the ability to order runtime plugins within the
service/operation plugin "levels".
- Adding an argument to `RuntimePlugin::runtime_components` so that
implementations can reference components configured by previous plugins.

The `order` function has three separate order values: `Defaults`,
`Overrides`, and `NestedComponents`. The `Defaults` order is currently
unused, but will be used later when we refactor how defaults in config
work. Everything defaults to `Overrides` since most runtime plugins will
want to be in this slot. The `NestedComponents` order is specifically
for runtime plugins that want to create nested components, and runs at
the very end.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent b84c02bb
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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"]
+4 −1
Original line number Diff line number Diff line
@@ -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)
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -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)
                }
            }
+1 −1
Original line number Diff line number Diff line
@@ -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};
+1 −1
Original line number Diff line number Diff line
@@ -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)
                }
            }
Loading