Unverified Commit 3bf906fe authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Improve log messaging around missing sleep implementation (#907)



* Improve missing sleep warning

* Update changelog

Co-authored-by: default avatarRussell Cohen <rcoh@amazon.com>
parent d293ab34
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -10,6 +10,25 @@
# references = ["smithy-rs#920"]
# meta = { "breaking" = false, "tada" = false, "bug" = false }
# author = "rcoh"

[[aws-sdk-rust]]
message = """
Removed inaccurate log message when a client was used without a sleep implementation, and
improved context and call to action in logged messages around missing sleep implementations.
"""
references = ["aws-sdk-rust#317", "smithy-rs#907"]
meta = { "breaking" = false, "tada" = false, "bug" = true }
author = "jdisanti"

[[smithy-rs]]
message = """
Removed spamming log message when a client was used without a sleep implementation, and
improved context and call to action in logged messages around missing sleep implementations.
"""
references = ["aws-sdk-rust#317", "smithy-rs#907"]
meta = { "breaking" = false, "tada" = false, "bug" = true }
author = "jdisanti"

[[aws-sdk-rust]]
message = "Use provided `sleep_impl` for retries instead of using Tokio directly."
references = ["smithy-rs#923"]
+67 −12
Original line number Diff line number Diff line
@@ -16,8 +16,10 @@ import software.amazon.smithy.rust.codegen.smithy.generators.config.ServiceConfi

/* Example Generated Code */
/*
/// Service config.
///
pub struct Config {
    pub(crate) sleep_impl: Option<Arc<dyn AsyncSleep>>,
    pub(crate) sleep_impl: Option<std::sync::Arc<dyn aws_smithy_async::rt::sleep::AsyncSleep>>,
}
impl std::fmt::Debug for Config {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@@ -26,39 +28,90 @@ impl std::fmt::Debug for Config {
    }
}
impl Config {
    /// Constructs a config builder.
    pub fn builder() -> Builder {
        Builder::default()
    }
}
/// Builder for creating a `Config`.
#[derive(Default)]
pub struct Builder {
    sleep_impl: Option<Arc<dyn AsyncSleep>>,
    sleep_impl: Option<std::sync::Arc<dyn aws_smithy_async::rt::sleep::AsyncSleep>>,
}
impl Builder {
    /// Constructs a config builder.
    pub fn new() -> Self {
        Self::default()
    }
    pub fn sleep_impl(mut self, sleep_impl: Arc<dyn AsyncSleep>) -> Self {
    /// Set the sleep_impl for the builder
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use test_smithy_test1832442648477221704::config::Config;
    /// use aws_smithy_async::rt::sleep::AsyncSleep;
    /// use aws_smithy_async::rt::sleep::Sleep;
    ///
    /// #[derive(Debug)]
    /// pub struct ForeverSleep;
    ///
    /// impl AsyncSleep for ForeverSleep {
    ///     fn sleep(&self, duration: std::time::Duration) -> Sleep {
    ///         Sleep::new(std::future::pending())
    ///     }
    /// }
    ///
    /// let sleep_impl = std::sync::Arc::new(ForeverSleep);
    /// let config = Config::builder().sleep_impl(sleep_impl).build();
    /// ```
    pub fn sleep_impl(
        mut self,
        sleep_impl: std::sync::Arc<dyn aws_smithy_async::rt::sleep::AsyncSleep>,
    ) -> Self {
        self.set_sleep_impl(Some(sleep_impl));
        self
    }

    /// Set the sleep_impl for the builder
    ///
    /// # Examples
    ///
    /// ```no_run
    /// use test_smithy_test1832442648477221704::config::{Builder, Config};
    /// use aws_smithy_async::rt::sleep::AsyncSleep;
    /// use aws_smithy_async::rt::sleep::Sleep;
    ///
    /// #[derive(Debug)]
    /// pub struct ForeverSleep;
    ///
    /// impl AsyncSleep for ForeverSleep {
    ///     fn sleep(&self, duration: std::time::Duration) -> Sleep {
    ///         Sleep::new(std::future::pending())
    ///     }
    /// }
    ///
    /// fn set_never_ending_sleep_impl(builder: &mut Builder) {
    ///     let sleep_impl = std::sync::Arc::new(ForeverSleep);
    ///     builder.set_sleep_impl(Some(sleep_impl));
    /// }
    ///
    /// let mut builder = Config::builder();
    /// set_never_ending_sleep_impl(&mut builder);
    /// let config = builder.build();
    /// ```
    pub fn set_sleep_impl(
        &mut self,
        sleep_impl: Option<Arc<dyn AsyncSleep>>,
        sleep_impl: Option<std::sync::Arc<dyn aws_smithy_async::rt::sleep::AsyncSleep>>,
    ) -> &mut Self {
        self.sleep_impl = sleep_impl;
        self
    }
    /// Builds a [`Config`].
    pub fn build(self) -> Config {
        Config {
            sleep_impl: self.sleep_impl,
            sleep_impl: self.sleep_impl
        }
    }
}
#[test]
fn test_1() {
    fn assert_send_sync<T: Send + Sync>() {}
    assert_send_sync::<Config>();
}
 */

@@ -77,8 +130,10 @@ class SleepImplDecorator : RustCodegenDecorator {
class SleepImplProviderConfig(codegenContext: CodegenContext) : ConfigCustomization() {
    private val sleepModule = smithyAsyncRtSleep(codegenContext.runtimeConfig)
    private val moduleUseName = codegenContext.moduleUseName()
    private val codegenScope =
        arrayOf("AsyncSleep" to sleepModule.member("AsyncSleep"), "Sleep" to sleepModule.member("Sleep"))
    private val codegenScope = arrayOf(
        "AsyncSleep" to sleepModule.member("AsyncSleep"),
        "Sleep" to sleepModule.member("Sleep"),
    )

    override fun section(section: ServiceConfig) = writable {
        when (section) {
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ import software.amazon.smithy.rust.codegen.testutil.rustSettings
import software.amazon.smithy.rust.codegen.testutil.testCodegenContext
import software.amazon.smithy.rust.codegen.testutil.validateConfigCustomizations

internal class RetryConfigProviderConfigTest {
internal class RetryConfigDecoratorTest {
    private val baseModel = """
        namespace test
        use aws.protocols#awsQuery
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ import software.amazon.smithy.rust.codegen.testutil.rustSettings
import software.amazon.smithy.rust.codegen.testutil.testCodegenContext
import software.amazon.smithy.rust.codegen.testutil.validateConfigCustomizations

internal class SleepImplProviderConfigTest {
internal class SleepImplDecoratorTest {
    private val baseModel = """
        namespace test
        use aws.protocols#awsQuery
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ import software.amazon.smithy.rust.codegen.testutil.rustSettings
import software.amazon.smithy.rust.codegen.testutil.testCodegenContext
import software.amazon.smithy.rust.codegen.testutil.validateConfigCustomizations

internal class TimeoutConfigProviderConfigTest {
internal class TimeoutConfigDecoratorTest {
    private val baseModel = """
        namespace test
        use aws.protocols#awsQuery
Loading