Skip to content

Conversation

dayaffe
Copy link
Contributor

@dayaffe dayaffe commented Sep 15, 2025

Issue #

Description of changes

Scope

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dayaffe dayaffe requested a review from jbelkins September 16, 2025 17:07

do {
// Read a chunk from the stream (using default chunk size)
let data = try await stream.readAsync(upToCount: CHUNK_SIZE_BYTES)
Copy link
Contributor Author

@dayaffe dayaffe Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to proposals on alternative methods of doing this. Intention behind this is to read a chunk at a time from our Smithy stream in order to write it to AsyncHTTPClient stream. CHUNK_SIZE_BYTES here is reused from the S3 chunking which I believe is 64 kb.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with 64kb for production use, but the value should probably be configurable, if only for testing

Copy link
Contributor

@jbelkins jbelkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple questions inline.

I also think we should have tests around this stream bridge, for an example see:
https://github.com/smithy-lang/smithy-swift/blob/main/Tests/ClientRuntimeTests/NetworkingTests/URLSession/FoundationStreamBridgeTests.swift

let bufferedStream = BufferedStream()

// Start a background task to stream data from AsyncHTTPClient to BufferedStream
Task {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where will this function get called from? If it is called from an async context, I would think it better to not create a Task here.


struct AsyncIterator: AsyncIteratorProtocol {
private let stream: Smithy.Stream
private let allocator: ByteBufferAllocator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where do we get this allocator from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ByteBufferAllocator is a struct from NIOCore package utilized by async-http-client


do {
// Read a chunk from the stream (using default chunk size)
let data = try await stream.readAsync(upToCount: CHUNK_SIZE_BYTES)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with 64kb for production use, but the value should probably be configurable, if only for testing

@dayaffe dayaffe requested a review from jbelkins September 23, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants