-
Notifications
You must be signed in to change notification settings - Fork 192
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
Avoid exposing aws_smithy_http::event_stream::receiver::Receiver
in SDK's public API
#3114
Conversation
A new generated diff is ready to view.
A new doc preview is ready to view. |
...tlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt
Show resolved
Hide resolved
Do you think we should also wrap the It seems like one of the advantages to wrapping the receiver is that we get to properly hide methods such as |
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
Yeah, I can see value in doing that, benefiting the event sender the same way it benefited the event receiver. Two things:
So all in all, I think it's worth tracking it via an issue. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
…thy-eventstream` to `aws-smithy-types` (#3139) ## Motivation and Context Fixes the following statement in #3114 > A notable breaking change is the error type of the new recv method. Previously, it was [SdkError<E, RawMessage>>](https://docs.rs/aws-smithy-http/0.57.0/aws_smithy_http/event_stream/struct.Receiver.html#method.recv) but it is now a BoxError. This means that upon an event receive error, customers can only show what the error is, but not match on it and take some actions. so that the `recv` method on a new-type wrapper `aws_smithy_http::event_stream::Receiver` can expose `SdkError<E, RawMessage>>` in public API. It is the responsibility of the above PR to move [RawMessage](https://github.com/awslabs/smithy-rs/blob/c7f0d5dc33937d65841d74b5b828cc77ed1d2db4/rust-runtime/aws-smithy-http/src/event_stream/receiver.rs#L92-L98) from `aws-smithy-http` to `aws-smithy-types` but doing so first requires `Message` to be moved to `aws-smithy-types`, hence this PR. ## Description Moving `Message` to `aws-smithy-types` also requires moving the types it depends upon, namely `Header`, `HederValue`, and `StrBytes`. However, their serialization/deserialization methods (`read_from` and `write_to`) remain in `aws-smithy-eventstream` and they are converted to free functions, with the aim of moving things as minimally as possible. `aws-smithy-eventstream` has fuzz testing. It previously implemented the `Arbitrary` trait for moved types, but since they are now in `aws-smithy-types`, we need to have newtypes for them to enable the trait due to the orphan rules. A newly added module `aws-smithy-eventstream::arbitrary` is exactly for that purpose. ## Testing Relied on the existing tests. ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [x] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
A new generated diff is ready to view.
A new doc preview is ready to view. |
…rom `aws-smithy-eventstream` to `aws-smithy-types` (#3139) ## Motivation and Context Fixes the following statement in smithy-lang/smithy-rs#3114 > A notable breaking change is the error type of the new recv method. Previously, it was [SdkError<E, RawMessage>>](https://docs.rs/aws-smithy-http/0.57.0/aws_smithy_http/event_stream/struct.Receiver.html#method.recv) but it is now a BoxError. This means that upon an event receive error, customers can only show what the error is, but not match on it and take some actions. so that the `recv` method on a new-type wrapper `aws_smithy_http::event_stream::Receiver` can expose `SdkError<E, RawMessage>>` in public API. It is the responsibility of the above PR to move [RawMessage](https://github.com/awslabs/smithy-rs/blob/c7f0d5dc33937d65841d74b5b828cc77ed1d2db4/rust-runtime/aws-smithy-http/src/event_stream/receiver.rs#L92-L98) from `aws-smithy-http` to `aws-smithy-types` but doing so first requires `Message` to be moved to `aws-smithy-types`, hence this PR. ## Description Moving `Message` to `aws-smithy-types` also requires moving the types it depends upon, namely `Header`, `HederValue`, and `StrBytes`. However, their serialization/deserialization methods (`read_from` and `write_to`) remain in `aws-smithy-eventstream` and they are converted to free functions, with the aim of moving things as minimally as possible. `aws-smithy-eventstream` has fuzz testing. It previously implemented the `Arbitrary` trait for moved types, but since they are now in `aws-smithy-types`, we need to have newtypes for them to enable the trait due to the orphan rules. A newly added module `aws-smithy-eventstream::arbitrary` is exactly for that purpose. ## Testing Relied on the existing tests. ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [x] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
## Motivation and Context Adds re-export for `EventReceiver` in a generated client crate ## Description `EventReceiver` was added in #3114 but the struct itself could not be referenced as `pub`. Our SDK integration tests did not break in the said PR because they only called the `next` method on it and never referred to that struct name. This PR adds a re-export for `EventReceiver` in case customers need to refer to the name in their code. ## Testing Added a unit test and edited a `transcribestreaming` integration test to verify the re-export. ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [x] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: AWS SDK Rust Bot <[email protected]>
Motivation and Context
Implements #3100
Description
Currently, we expose
aws_smithy_http::event_stream::Receiver
in generated SDKs, as shown in the following S3's example (see a generated diff fortmp-codegen-diff/aws-sdk/sdk/s3/src/operation/select_object_content/_select_object_content_output.rs
):This PR wraps
Receiver
in a new-type, calledEventReceiver
, which then supportspub async fn recv
method whose signature is the same asaws_smithy_http::event_stream::Receiver::recv
.Testing
Relied on existing tests (e.g.
s3
andtranscribestreaming
integration tests cover uses cases affected by this change).Checklist
CHANGELOG.next.toml
if I made changes to the smithy-rs codegen or runtime cratesCHANGELOG.next.toml
if I made changes to the AWS SDK, generated SDK code, or SDK runtime cratesBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.