Unverified Commit 637333c1 authored by Zelda Hessler's avatar Zelda Hessler Committed by GitHub
Browse files

Add stubs to make SRA test fully runnable (#2519)

* add: stubs to make sra test fully runnable (but not useful 😅

)

* fix: disable build.gradle enableNewSmithyRuntime option

* fix: clippy lints
add: feature gate for test connection

* fix: doc comment

* move: connections module from API to runtime

* update: TODO message
add: exceptions for external types

* Fix external types lint

---------

Co-authored-by: default avatarJohn DiSanti <jdisanti@amazon.com>
parent b023426d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ aws-smithy-client = { path = "../../../../rust-runtime/aws-smithy-client" }
aws-smithy-types = { path = "../../../../rust-runtime/aws-smithy-types" }
aws-smithy-http = { path = "../../../../rust-runtime/aws-smithy-http" }
aws-smithy-runtime = { path = "../../../../rust-runtime/aws-smithy-runtime" }
aws-smithy-runtime-api = { path = "../../../../rust-runtime/aws-smithy-runtime-api" }
aws-smithy-runtime-api = { path = "../../../../rust-runtime/aws-smithy-runtime-api", features = ["test-util"] }
tokio = { version = "1.23.1", features = ["macros", "test-util", "rt-multi-thread"] }
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.15", features = ["env-filter", "json"] }
+21 −8
Original line number Diff line number Diff line
@@ -19,28 +19,41 @@ class ServiceRuntimePluginGenerator(
    private val codegenScope = codegenContext.runtimeConfig.let { rc ->
        arrayOf(
            "BoxError" to RuntimeType.smithyRuntimeApi(rc).resolve("client::runtime_plugin::BoxError"),
            "NeverRetryStrategy" to RuntimeType.smithyRuntimeApi(rc).resolve("client::retries::NeverRetryStrategy"),
            "ConfigBag" to RuntimeType.smithyRuntimeApi(rc).resolve("config_bag::ConfigBag"),
            "ConfigBagAccessors" to RuntimeType.smithyRuntimeApi(rc).resolve("client::orchestrator::ConfigBagAccessors"),
            "TestConnection" to RuntimeType.smithyRuntimeApi(rc).resolve("client::connections::test_connection::TestConnection"),
            "RuntimePlugin" to RuntimeType.smithyRuntimeApi(rc).resolve("client::runtime_plugin::RuntimePlugin"),
            "StaticUriEndpointResolver" to RuntimeType.smithyRuntimeApi(rc).resolve("client::endpoints::StaticUriEndpointResolver"),
            "StubAuthOptionResolver" to RuntimeType.smithyRuntimeApi(rc).resolve("client::auth::option_resolver::StubAuthOptionResolver"),
            "StubAuthOptionResolverParams" to RuntimeType.smithyRuntimeApi(rc).resolve("client::auth::option_resolver::StubAuthOptionResolverParams"),
            "AuthOptionResolverParams" to RuntimeType.smithyRuntimeApi(rc).resolve("client::orchestrator::AuthOptionResolverParams"),
            "IdentityResolvers" to RuntimeType.smithyRuntimeApi(rc).resolve("client::orchestrator::IdentityResolvers"),
        )
    }

    fun render(writer: RustWriter) {
        writer.rustTemplate(
            """
            pub(crate) struct ServiceRuntimePlugin;
            pub(crate) struct ServiceRuntimePlugin {
                handle: std::sync::Arc<crate::client::Handle>,
            }

            impl ServiceRuntimePlugin {
                pub fn new() -> Self { Self }
                pub fn new(handle: std::sync::Arc<crate::client::Handle>) -> Self { Self { handle } }
            }

            impl #{RuntimePlugin} for ServiceRuntimePlugin {
                fn configure(&self, _cfg: &mut #{ConfigBag}) -> Result<(), #{BoxError}> {
                    // TODO(RuntimePlugins): Add the AuthOptionResolver to the config bag
                    // TODO(RuntimePlugins): Add the EndpointResolver to the config bag
                    // TODO(RuntimePlugins): Add the IdentityResolver to the config bag
                    // TODO(RuntimePlugins): Add the Connection to the config bag
                fn configure(&self, cfg: &mut #{ConfigBag}) -> Result<(), #{BoxError}> {
                    use #{ConfigBagAccessors};

                    cfg.set_identity_resolvers(#{IdentityResolvers}::builder().build());
                    cfg.set_auth_option_resolver_params(#{AuthOptionResolverParams}::new(#{StubAuthOptionResolverParams}::new()));
                    cfg.set_auth_option_resolver(#{StubAuthOptionResolver}::new());
                    cfg.set_endpoint_resolver(#{StaticUriEndpointResolver}::default());
                    cfg.set_retry_strategy(#{NeverRetryStrategy}::new());
                    cfg.set_connection(#{TestConnection}::new(vec![]));
                    // TODO(RuntimePlugins): Add the HttpAuthSchemes to the config bag
                    // TODO(RuntimePlugins): Add the RetryStrategy to the config bag
                    // TODO(RuntimePlugins): Add the TraceProbe to the config bag
                    Ok(())
                }
+1 −1
Original line number Diff line number Diff line
@@ -330,7 +330,7 @@ class FluentClientGenerator(
                    /// set when configuring the client.
                    pub async fn send_v2(self) -> std::result::Result<#{OperationOutput}, #{SdkError}<#{OperationError}, #{HttpResponse}>> {
                        let runtime_plugins = #{RuntimePlugins}::new()
                            .with_client_plugin(crate::config::ServiceRuntimePlugin::new())
                            .with_client_plugin(crate::config::ServiceRuntimePlugin::new(self.handle.clone()))
                            .with_operation_plugin(#{Operation}::new());
                        let input = self.inner.build().map_err(#{SdkError}::construction_failure)?;
                        let input = #{TypedBox}::new(input).erase();
+1 −0
Original line number Diff line number Diff line
@@ -4,4 +4,5 @@ allowed_external_types = [

    "http::request::Request",
    "http::response::Response",
    "http::uri::Uri",
]
+6 −0
Original line number Diff line number Diff line
@@ -20,3 +20,9 @@ pub mod orchestrator;
pub mod retries;
/// Runtime plugin type definitions.
pub mod runtime_plugin;

/// Smithy endpoint resolution runtime plugins
pub mod endpoints;

/// Smithy auth runtime plugins
pub mod auth;
Loading