Skip to content
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

Provide AsyncFileStreaming API #3184

Merged
merged 36 commits into from May 7, 2024
Merged

Provide AsyncFileStreaming API #3184

merged 36 commits into from May 7, 2024

Conversation

0xTim
Copy link
Member

@0xTim 0xTim commented Apr 30, 2024

These changes are now available in 4.97.0

Builds on the work of #2998, #3170 and #3167 to provide a full async streaming API that can be used in Swift Concurrency environments:

  • Provides a new asyncStreamFile(at:chunkSize:mediaType:advancedETagComparison:onCompleted:) that takes advantage of the full async response streaming
  • Fixes a number of bugs with the async Response body streaming
  • FileMiddleware is now an AsyncMiddleware
  • Replaces usages of FileManager with NIOFileSystem apart from in one deprecated API that can't be async
  • Correctly marks XCTVapor functions as noasync where they use .wait() and provides proper async alternatives

@0xTim 0xTim requested a review from gwynne as a code owner April 30, 2024 23:27
@0xTim 0xTim added the semver-minor Contains new API label Apr 30, 2024
@0xTim
Copy link
Member Author

0xTim commented Apr 30, 2024

The stream file functions could use some tidying up as there's a lot of duplicated code there

gwynne and others added 24 commits May 1, 2024 00:47
…ams while cascading errors thrown from the stream callback to the promise.
… (in which assertions like the one in ChannelResponseBodyStream's deinit aren't checked).
…ase even if trying to write the error indication to the stream fails
…atomics, and to handle errors and the promise completions more consistently. Especially affects async streaming, but eliminates error handling issues in non-async streaming as well.
This reverts commit c98f0bf.
Copy link
Member

@gwynne gwynne left a comment

Choose a reason for hiding this comment

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

A few nits about behavior

Sources/Vapor/HTTP/Server/HTTPServerHandler.swift Outdated Show resolved Hide resolved
Sources/Vapor/HTTP/Server/HTTPServerHandler.swift Outdated Show resolved Hide resolved
Sources/Vapor/Response/Response+Body.swift Show resolved Hide resolved
Sources/Vapor/Utilities/FileIO.swift Outdated Show resolved Hide resolved
Sources/Vapor/Utilities/FileIO.swift Outdated Show resolved Hide resolved
Sources/Vapor/Utilities/FileIO.swift Outdated Show resolved Hide resolved
Sources/Vapor/Utilities/FileIO.swift Outdated Show resolved Hide resolved
@0xTim 0xTim merged commit cdbbd04 into main May 7, 2024
15 of 16 checks passed
@0xTim 0xTim deleted the async-file-streaming branch May 7, 2024 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor Contains new API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants