Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide AsyncFileStreaming API (#3184)
* Provide async stream implemetation * Add AsyncFileTests * Fix double/int bug * Allow the stream writer to complete the writer promise for async streams while cascading errors thrown from the stream callback to the promise. * Use the same ordering for both stores to the isComplete atomic in ChannelResponseBodyStream * Actually call the onCompleted() callback in asyncStreamFile() * Make sure the promise is never dropped on the floor in release builds (in which assertions like the one in ChannelResponseBodyStream's deinit aren't checked). * Make completion handler async * Use NIOFilesytemFoundationCompat * Fix imports * Make sure the NIO FileHandle is always closed on error. * Make sure the onCompleted() callback is always invoked in the error case even if trying to write the error indication to the stream fails * Migrate old ELF stream file function to use async version under the hood * Migrate FileMiddleware to async * Heavily revise ChannelResponseBodyStream's logic to eliminate races, 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. * Fix off-by-one error in FileIO.readFile(at:chunkSize:offset:byteCount:) async * Use XCTAssertNoThrow() to simplify several of the AsyncFileTests * Fix testSimpleETagHeaders test * Add async versions for XCTVapor and mark wait() calls with noasync * Fix XCTVapor error messages * Try and make tests async * Fix some warnings in tests * One less test running on 8080 * Fix the tests * Revert "Fix the tests" This reverts commit c98f0bf. * Hook up the response body callback for async streams * Remove a couple of instances of FileManager * Remove FileManager from AsyncFileTests * Fix default file * Fix the tests * Rework it to reduce all the returns * Update Sources/Vapor/Utilities/FileIO.swift Co-authored-by: Gwynne Raskind <gwynne@vapor.codes> * PR Reviews * Fix merge issue: * Test the correct behaviour --------- Co-authored-by: Gwynne Raskind <gwynne@vapor.codes>
- Loading branch information
Showing
14 changed files
with
795 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.