From 3fb027eaf0182b68e396f0946e77caaa40604e77 Mon Sep 17 00:00:00 2001 From: ysaito1001 Date: Mon, 11 Dec 2023 14:02:09 -0600 Subject: [PATCH 1/6] Reexport `EventReceiver` in a generated client crate --- .../customizations/SmithyTypesPubUseExtra.kt | 3 ++ .../SmithyTypesPubUseExtraTest.kt | 48 +++++++++++++++---- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtra.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtra.kt index 2a285ca13f..6300a7d624 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtra.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtra.kt @@ -14,6 +14,7 @@ import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate import software.amazon.smithy.rust.codegen.core.rustlang.writable import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType +import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType.Companion.eventReceiver import software.amazon.smithy.rust.codegen.core.smithy.RustCrate import software.amazon.smithy.rust.codegen.core.util.hasEventStreamMember import software.amazon.smithy.rust.codegen.core.util.hasEventStreamOperations @@ -88,11 +89,13 @@ fun pubUseSmithyPrimitivesEventStream(codegenContext: CodegenContext, model: Mod if (codegenContext.serviceShape.hasEventStreamOperations(model)) { rustTemplate( """ + pub use #{EventReceiver}; pub use #{Header}; pub use #{HeaderValue}; pub use #{Message}; pub use #{StrBytes}; """, + "EventReceiver" to eventReceiver(rc), "Header" to RuntimeType.smithyTypes(rc).resolve("event_stream::Header"), "HeaderValue" to RuntimeType.smithyTypes(rc).resolve("event_stream::HeaderValue"), "Message" to RuntimeType.smithyTypes(rc).resolve("event_stream::Message"), diff --git a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtraTest.kt b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtraTest.kt index f9eda03a43..14e8426c47 100644 --- a/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtraTest.kt +++ b/codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/customizations/SmithyTypesPubUseExtraTest.kt @@ -10,7 +10,6 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.rust.codegen.core.rustlang.RustWriter import software.amazon.smithy.rust.codegen.core.smithy.CodegenContext import software.amazon.smithy.rust.codegen.core.smithy.RustCrate -import software.amazon.smithy.rust.codegen.core.smithy.generators.StructureGeneratorTest.Companion.model import software.amazon.smithy.rust.codegen.core.testutil.asSmithyModel import software.amazon.smithy.rust.codegen.core.testutil.generatePluginContext import software.amazon.smithy.rust.codegen.core.testutil.testCodegenContext @@ -25,6 +24,11 @@ class SmithyTypesPubUseExtraTest { return """ namespace test + service TestService { + version: "123" + operations: [SomeOperation] + } + $additionalShape structure SomeStruct { } @@ -46,20 +50,21 @@ class SmithyTypesPubUseExtraTest { """.asSmithyModel() } - private val rustCrate: RustCrate - private val codegenContext: CodegenContext = testCodegenContext(model) + private fun initialize(model: Model): Pair { + val codegenContext = testCodegenContext(model) - init { val (context, _) = generatePluginContext( model, runtimeConfig = codegenContext.runtimeConfig, ) - rustCrate = RustCrate( + val rustCrate = RustCrate( context.fileManifest, codegenContext.symbolProvider, codegenContext.settings.codegenConfig, codegenContext.expectModuleDocProvider(), ) + + return Pair(codegenContext, rustCrate) } private fun reexportsWithEmptyModel() = reexportsWithMember() @@ -69,11 +74,12 @@ class SmithyTypesPubUseExtraTest { unionMember: String = "", additionalShape: String = "", ) = RustWriter.root().let { writer -> - pubUseSmithyPrimitives( - codegenContext, - modelWithMember(inputMember, outputMember, unionMember, additionalShape), - rustCrate, - )(writer) + val model = modelWithMember(inputMember, outputMember, unionMember, additionalShape) + val props = initialize(model) + val context = props.first + val rustCrate = props.second + pubUseSmithyPrimitives(context, model, rustCrate)(writer) + pubUseSmithyPrimitivesEventStream(context, model)(writer) writer.toString() } @@ -151,4 +157,26 @@ class SmithyTypesPubUseExtraTest { streamingTypes, ) } + + @Test + fun `it re-exports when a model has event stream`() { + val eventStreamTypes = + listOf( + "crate::event_receiver::EventReceiver", + "::aws_smithy_types::event_stream::Header", + "::aws_smithy_types::event_stream::HeaderValue", + "::aws_smithy_types::event_stream::Message", + "::aws_smithy_types::str_bytes::StrBytes", + ) + val eventStreamShape = "@streaming union EventStream { foo: SomeStruct }" + + assertHasReexports( + reexportsWithMember(additionalShape = eventStreamShape, inputMember = "m: EventStream"), + eventStreamTypes, + ) + assertHasReexports( + reexportsWithMember(additionalShape = eventStreamShape, outputMember = "m: EventStream"), + eventStreamTypes, + ) + } } From d222fc1b7eb8c97ea99f987c76173b603b910349 Mon Sep 17 00:00:00 2001 From: ysaito1001 Date: Mon, 11 Dec 2023 14:13:16 -0600 Subject: [PATCH 2/6] Add `use` statement to check `EventReceiver` re-export --- aws/sdk/integration-tests/transcribestreaming/tests/test.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aws/sdk/integration-tests/transcribestreaming/tests/test.rs b/aws/sdk/integration-tests/transcribestreaming/tests/test.rs index 5178bd2ae9..f1050cb469 100644 --- a/aws/sdk/integration-tests/transcribestreaming/tests/test.rs +++ b/aws/sdk/integration-tests/transcribestreaming/tests/test.rs @@ -8,6 +8,8 @@ use aws_sdk_transcribestreaming::config::{Credentials, Region}; use aws_sdk_transcribestreaming::error::SdkError; use aws_sdk_transcribestreaming::operation::start_stream_transcription::StartStreamTranscriptionOutput; use aws_sdk_transcribestreaming::primitives::event_stream::{HeaderValue, Message}; +#[allow(unused)] // making sure `EventReceiver` is re-exported +use aws_sdk_transcribestreaming::primitives::event_stream::EventReceiver; use aws_sdk_transcribestreaming::primitives::Blob; use aws_sdk_transcribestreaming::types::error::{AudioStreamError, TranscriptResultStreamError}; use aws_sdk_transcribestreaming::types::{ From fd2168740fa9e34e459d7e1a78d43cd4ebdf9b3c Mon Sep 17 00:00:00 2001 From: ysaito1001 Date: Mon, 11 Dec 2023 14:22:35 -0600 Subject: [PATCH 3/6] Update CHANGELOG.next.toml --- CHANGELOG.next.toml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 77a969b194..94e410f148 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -97,3 +97,15 @@ message = "[`Number`](https://docs.rs/aws-smithy-types/latest/aws_smithy_types/e references = ["smithy-rs#3294"] meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "all" } author = "rcoh" + +[[smithy-rs]] +message = "`crate::event_receiver::EventReceiver` is now re-exported as `crate::primitives::event_stream::EventReceiver` when a service supports event stream operations." +references = ["smithy-rs#3305"] +meta = { "breaking" = false, "tada" = false, "bug" = true, "target" = "client" } +author = "ysaito1001" + +[[aws-sdk-rust]] +message = "`crate::event_receiver::EventReceiver` is now re-exported as `crate::primitives::event_stream::EventReceiver` when a service supports event stream operations." +references = ["smithy-rs#3305"] +meta = { "breaking" = false, "tada" = false, "bug" = true } +author = "ysaito1001" From ca58fd7aa6859ad539d98e7c96fb516d42b6deec Mon Sep 17 00:00:00 2001 From: ysaito1001 Date: Mon, 11 Dec 2023 14:24:46 -0600 Subject: [PATCH 4/6] Fix `cargo fmt` --- aws/sdk/integration-tests/transcribestreaming/tests/test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/sdk/integration-tests/transcribestreaming/tests/test.rs b/aws/sdk/integration-tests/transcribestreaming/tests/test.rs index f1050cb469..5b761eba2c 100644 --- a/aws/sdk/integration-tests/transcribestreaming/tests/test.rs +++ b/aws/sdk/integration-tests/transcribestreaming/tests/test.rs @@ -7,9 +7,9 @@ use async_stream::stream; use aws_sdk_transcribestreaming::config::{Credentials, Region}; use aws_sdk_transcribestreaming::error::SdkError; use aws_sdk_transcribestreaming::operation::start_stream_transcription::StartStreamTranscriptionOutput; -use aws_sdk_transcribestreaming::primitives::event_stream::{HeaderValue, Message}; #[allow(unused)] // making sure `EventReceiver` is re-exported use aws_sdk_transcribestreaming::primitives::event_stream::EventReceiver; +use aws_sdk_transcribestreaming::primitives::event_stream::{HeaderValue, Message}; use aws_sdk_transcribestreaming::primitives::Blob; use aws_sdk_transcribestreaming::types::error::{AudioStreamError, TranscriptResultStreamError}; use aws_sdk_transcribestreaming::types::{ From 56ebae0ea869905fd61a9a22cb020dbd4f9d206f Mon Sep 17 00:00:00 2001 From: AWS SDK Rust Bot Date: Fri, 8 Dec 2023 22:38:01 +0000 Subject: [PATCH 5/6] Upgrade the smithy-rs runtime crates version to 1.1.0 --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index ed4fedc5e4..9724fcca4d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,10 +12,10 @@ rust.msrv=1.70.0 org.gradle.jvmargs=-Xmx1024M # Version number to use for the generated stable runtime crates -smithy.rs.runtime.crate.stable.version=1.0.3 +smithy.rs.runtime.crate.stable.version=1.1.0 # Version number to use for the generated unstable runtime crates -smithy.rs.runtime.crate.unstable.version=0.60.0 +smithy.rs.runtime.crate.unstable.version=0.61.0 kotlin.code.style=official From 3bf9781a4d4d16d8eb2005e246fe05ed14759bbe Mon Sep 17 00:00:00 2001 From: AWS SDK Rust Bot Date: Fri, 8 Dec 2023 22:39:53 +0000 Subject: [PATCH 6/6] Update changelog --- CHANGELOG.md | 15 +++++ CHANGELOG.next.toml | 87 ---------------------------- aws/SDK_CHANGELOG.next.json | 111 ++++++++++++++++++++++++++++++------ 3 files changed, 108 insertions(+), 105 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86150e6ba4..b8c87f438a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,19 @@ +December 8th, 2023 +================== +**New this release:** +- :tada: (all, [smithy-rs#3121](https://github.com/smithy-lang/smithy-rs/issues/3121), [smithy-rs#3295](https://github.com/smithy-lang/smithy-rs/issues/3295)) All generated docs now include docsrs labels when features are required +- :bug: (client, [smithy-rs#3262](https://github.com/smithy-lang/smithy-rs/issues/3262)) Loading native TLS trusted certs for the default HTTP client now only occurs if the default HTTP client is not overridden in config. +- (client, [smithy-rs#3277](https://github.com/smithy-lang/smithy-rs/issues/3277)) Improve the error messages for when auth fails to select an auth scheme for a request. +- (client, [smithy-rs#3282](https://github.com/smithy-lang/smithy-rs/issues/3282)) Fix documentation and examples on HyperConnector and HyperClientBuilder. +- (client, [aws-sdk-rust#990](https://github.com/awslabs/aws-sdk-rust/issues/990), @declanvk) Expose local socket address from ConnectionMetadata. +- (all, [smithy-rs#3294](https://github.com/smithy-lang/smithy-rs/issues/3294)) [`Number`](https://docs.rs/aws-smithy-types/latest/aws_smithy_types/enum.Number.html) `TryInto` implementations now succesfully convert from `f64` to numeric types when no precision is lost. This fixes some deserialization issues where numbers like `25.0` were sent when `Byte` fields were expected. + +**Contributors** +Thank you for your contributions! ❤ +- @declanvk ([aws-sdk-rust#990](https://github.com/awslabs/aws-sdk-rust/issues/990)) + + December 1st, 2023 ================== **New this release:** diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 94e410f148..472e7c8c2b 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -11,93 +11,6 @@ # meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client | server | all"} # author = "rcoh" -[[aws-sdk-rust]] -message = "Loading native TLS trusted certs for the default HTTP client now only occurs if the default HTTP client is not overridden in config." -references = ["smithy-rs#3262"] -meta = { "breaking" = false, "tada" = false, "bug" = true } -author = "jdisanti" - -[[smithy-rs]] -message = "Loading native TLS trusted certs for the default HTTP client now only occurs if the default HTTP client is not overridden in config." -references = ["smithy-rs#3262"] -meta = { "breaking" = false, "tada" = false, "bug" = true, "target" = "client" } -author = "jdisanti" - -[[aws-sdk-rust]] -message = """Client creation now takes microseconds instead of milliseconds. -Previously, it would take 2-3 milliseconds for each client instantiation due to time spent compiling regexes. -For applications that used several clients, this would increase start-up time in cases where it really matters, -such as for AWS Lambda cold starts. This time was improved by both changing regex implementation and caching the -result of the compilation.""" -references = ["aws-sdk-rust#975", "smithy-rs#3269"] -meta = { "breaking" = false, "tada" = true, "bug" = false } -author = "jdisanti" - -[[aws-sdk-rust]] -message = """Add `test_credentials` to `ConfigLoader` in `aws_config`. This allows the following pattern during tests: - -```rust -async fn main() { - let conf = aws_config::defaults(BehaviorVersion::latest()) - .test_credentials() - .await; -} -``` - -This is designed for unit tests and using local mocks like DynamoDB Local and LocalStack with the SDK. -""" -meta = { "breaking" = false, "tada" = true, "bug" = false } -author = "rcoh" -references = ["smithy-rs#3279", "aws-sdk-rust#971"] - -[[aws-sdk-rust]] -message = "Improve the error messages for when auth fails to select an auth scheme for a request." -references = ["aws-sdk-rust#979", "smithy-rs#3277"] -meta = { "breaking" = false, "tada" = false, "bug" = false } -author = "jdisanti" - -[[smithy-rs]] -message = "Improve the error messages for when auth fails to select an auth scheme for a request." -references = ["smithy-rs#3277"] -meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client" } -author = "jdisanti" - -[[aws-sdk-rust]] -message = "Fix documentation and examples on HyperConnector and HyperClientBuilder." -references = ["aws-sdk-rust#986", "smithy-rs#3282"] -meta = { "breaking" = false, "tada" = false, "bug" = false } -author = "jdisanti" - -[[smithy-rs]] -message = "Fix documentation and examples on HyperConnector and HyperClientBuilder." -references = ["smithy-rs#3282"] -meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client" } -author = "jdisanti" - -[[smithy-rs]] -message = "Expose local socket address from ConnectionMetadata." -references = ["aws-sdk-rust#990"] -meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client" } -author = "declanvk" - -[[smithy-rs]] -message = "All generated docs now include docsrs labels when features are required" -references = ["smithy-rs#3121", "smithy-rs#3295"] -meta = { "breaking" = false, "tada" = true, "bug" = false, "target" = "all" } -author = "rcoh" - -[[aws-sdk-rust]] -message = "All generated docs now include docsrs labels when features are required" -references = ["smithy-rs#3121", "smithy-rs#3295"] -meta = { "breaking" = false, "tada" = true, "bug" = false } -author = "rcoh" - -[[smithy-rs]] -message = "[`Number`](https://docs.rs/aws-smithy-types/latest/aws_smithy_types/enum.Number.html) `TryInto` implementations now succesfully convert from `f64` to numeric types when no precision is lost. This fixes some deserialization issues where numbers like `25.0` were sent when `Byte` fields were expected." -references = ["smithy-rs#3294"] -meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "all" } -author = "rcoh" - [[smithy-rs]] message = "`crate::event_receiver::EventReceiver` is now re-exported as `crate::primitives::event_stream::EventReceiver` when a service supports event stream operations." references = ["smithy-rs#3305"] diff --git a/aws/SDK_CHANGELOG.next.json b/aws/SDK_CHANGELOG.next.json index 8823e0a91a..ecef0ea4da 100644 --- a/aws/SDK_CHANGELOG.next.json +++ b/aws/SDK_CHANGELOG.next.json @@ -5,20 +5,6 @@ { "smithy-rs": [], "aws-sdk-rust": [ - { - "message": "Make properties of S3Control PublicAccessBlockConfiguration optional. Previously, they defaulted to false, but this created invalid requests.", - "meta": { - "bug": true, - "breaking": true, - "tada": false - }, - "author": "milesziemer", - "references": [ - "smithy-rs#3246" - ], - "since-commit": "e155c3048b9989fe406ef575d461ea01dfaf294c", - "age": 5 - }, { "message": "Allow `--` to be used in bucket names for S3", "meta": { @@ -31,7 +17,7 @@ "smithy-rs#3253" ], "since-commit": "48e3c95a3f10eebd5a637f8e7670c4232cdabbe4", - "age": 4 + "age": 5 }, { "message": "Retry additional classes of H2 errors (H2 GoAway & H2 ResetStream)", @@ -46,7 +32,7 @@ "aws-sdk-rust#858" ], "since-commit": "88970ba88ef45266aade152c7c1da8e90b24c0d7", - "age": 2 + "age": 3 }, { "message": "Make some properties for IoT types optional. Previously, they defaulted to false, but that isn't how the service actual works.", @@ -60,7 +46,7 @@ "smithy-rs#3256" ], "since-commit": "88970ba88ef45266aade152c7c1da8e90b24c0d7", - "age": 2 + "age": 3 }, { "message": "Fix `config::Builder::set_credentials_provider` to override a credentials provider previously set.", @@ -75,7 +61,7 @@ "smithy-rs#3278" ], "since-commit": "529b3f03e2b945ea2e5e879183ccfd8e74b7377c", - "age": 1 + "age": 2 }, { "message": "`config::Config::credentials_provider` has been broken since `release-2023-11-15` and is now marked as `deprecated` explicitly.", @@ -90,6 +76,95 @@ "smithy-rs#3278" ], "since-commit": "529b3f03e2b945ea2e5e879183ccfd8e74b7377c", + "age": 2 + }, + { + "message": "Loading native TLS trusted certs for the default HTTP client now only occurs if the default HTTP client is not overridden in config.", + "meta": { + "bug": true, + "breaking": false, + "tada": false + }, + "author": "jdisanti", + "references": [ + "smithy-rs#3262" + ], + "since-commit": "fc335cbc87e70aa63895828fca55b51795b94a6c", + "age": 1 + }, + { + "message": "Client creation now takes microseconds instead of milliseconds.\nPreviously, it would take 2-3 milliseconds for each client instantiation due to time spent compiling regexes.\nFor applications that used several clients, this would increase start-up time in cases where it really matters,\nsuch as for AWS Lambda cold starts. This time was improved by both changing regex implementation and caching the\nresult of the compilation.", + "meta": { + "bug": false, + "breaking": false, + "tada": true + }, + "author": "jdisanti", + "references": [ + "aws-sdk-rust#975", + "smithy-rs#3269" + ], + "since-commit": "fc335cbc87e70aa63895828fca55b51795b94a6c", + "age": 1 + }, + { + "message": "Add `test_credentials` to `ConfigLoader` in `aws_config`. This allows the following pattern during tests:\n\n```rust\nasync fn main() {\n let conf = aws_config::defaults(BehaviorVersion::latest())\n .test_credentials()\n .await;\n}\n```\n\nThis is designed for unit tests and using local mocks like DynamoDB Local and LocalStack with the SDK.\n", + "meta": { + "bug": false, + "breaking": false, + "tada": true + }, + "author": "rcoh", + "references": [ + "smithy-rs#3279", + "aws-sdk-rust#971" + ], + "since-commit": "fc335cbc87e70aa63895828fca55b51795b94a6c", + "age": 1 + }, + { + "message": "Improve the error messages for when auth fails to select an auth scheme for a request.", + "meta": { + "bug": false, + "breaking": false, + "tada": false + }, + "author": "jdisanti", + "references": [ + "aws-sdk-rust#979", + "smithy-rs#3277" + ], + "since-commit": "fc335cbc87e70aa63895828fca55b51795b94a6c", + "age": 1 + }, + { + "message": "Fix documentation and examples on HyperConnector and HyperClientBuilder.", + "meta": { + "bug": false, + "breaking": false, + "tada": false + }, + "author": "jdisanti", + "references": [ + "aws-sdk-rust#986", + "smithy-rs#3282" + ], + "since-commit": "fc335cbc87e70aa63895828fca55b51795b94a6c", + "age": 1 + }, + { + "message": "All generated docs now include docsrs labels when features are required", + "meta": { + "bug": false, + "breaking": false, + "tada": true + }, + "author": "rcoh", + "references": [ + "smithy-rs#3121", + "smithy-rs#3295" + ], + "since-commit": "fc335cbc87e70aa63895828fca55b51795b94a6c", "age": 1 } ],