-
Notifications
You must be signed in to change notification settings - Fork 53
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
Emit an io.Reader for streaming blobs #11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note, since io.Reader
is an interface we don't need to generate it as a *io.Reader
instead it can just be io.Reader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this account for the behavior differences between an stream used as input vs a stream used as output? For output stream, the member type should be an io.ReadCloser
, Where as input should only be io.Reader
.
This is under the assumption that streams must only be on the operation's top level input shapes. Does smithy allow a non-toplevel input/output shape to contain a Stream member ?
To extend on @skmcgrail comment, generated interface types should never be used as pointers. they should always be value as a general rule. Since interfaces are already a pointer, similar to maps and slices. |
Nope, wouldn't really make any sense.
No, you can't guarantee a given shape isn't used for only output or only input. I know we discussed making custom types for operation inputs / outputs, so that might be a customization we can do then. |
beb67d5
to
c7ac516
Compare
type CityImageData io.Reader Smithy won't be able to create a type alias of an interface. Go does not allow type alias of interfaces. The MediaType shapes probably will need to structures that contain a underlying reader. What populatees that media type's reader will be based on how it is used. e.g. streaming vs nested. type CityImageData struct {
io.Reader
}
type AsCityImageData(r io.Reader) *CityImageData { return &CityImageData{Reader: r} } Downside of this approach is that if the underlying |
We'll also want to be aware that the the existing SDK's designs treat input and output streams differently. Input stream being be an io.Reader, and output io.ReadCloser. The smithy generation could consider requiring an io.ReadCoser for input as well, but this is uncommon outside of the http.Client's Request since most ownership of Closing is expected to be the caller, not the callee. Utilities like ioutil.NopCloser are available if a user doesn't want Close to be called or dont' want to use a type that implements io.Closer. |
This updates blobs with the
streaming
trait toio.Reader
instead of[]byte
. They'll now look like:Or if they have the
mediatype
trait too:Note that this PR is dependent on this Smithy change. This PR is still merge-able. It'll run, but the code path is effectively dead until the Smithy PR is merged and this generator updates to that version.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.