mirror of
https://github.com/fsouza/fake-gcs-server.git
synced 2026-04-25 13:45:52 +03:00
[PR #882] [CLOSED] Streaming downloads #1002
Labels
No labels
bug
compatibility-issue
docker
documentation
enhancement
help wanted
needs information
pull-request
question
stale
unfortunate
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/fake-gcs-server#1002
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fsouza/fake-gcs-server/pull/882
Author: @StevenACoffman
Created: 8/4/2022
Status: ❌ Closed
Base:
main← Head:streaming-downloads📝 Commits (10+)
165bcd3Stream object downloads instead of buffering object in memory57d084cFix typo in xattr_windows.goec9f547Fix staticcheck lint errors.beded88Attempt to fix renaming over open files on Windowsc7d6f1dAdd build directive to rename_unix.go0cb0899Close objects when listing objects and in testsaf77c57Use compatOpenForWritingAllowingRename for temp file4639463Close temp file71201caMove the Windows "temporary delete path" to the temp dircbb36c8Close initial objects📊 Changes
21 files changed (+667 additions, -235 deletions)
View changed files
📝
.gitignore(+1 -0)📝
fakestorage/object.go(+158 -65)📝
fakestorage/object_test.go(+31 -17)📝
fakestorage/server.go(+2 -2)📝
fakestorage/server_test.go(+7 -4)📝
fakestorage/upload.go(+41 -41)📝
fakestorage/upload_test.go(+38 -9)📝
go.mod(+1 -0)📝
go.sum(+2 -0)📝
internal/backend/backend_test.go(+36 -13)📝
internal/backend/fs.go(+127 -47)📝
internal/backend/memory.go(+49 -22)📝
internal/backend/object.go(+38 -0)➕
internal/backend/rename_unix.go(+21 -0)➕
internal/backend/rename_windows.go(+54 -0)📝
internal/backend/storage.go(+6 -6)📝
internal/backend/xattr_unix.go(+4 -0)📝
internal/backend/xattr_windows.go(+4 -0)📝
internal/checksum/checksum.go(+29 -0)📝
internal/notification/event.go(+5 -5)...and 1 more files
📄 Description
Fixes #828. (This is #829 with the review requests applied)
This PR makes it so objects in the FS backend are streamed from disk instead of being loaded into memory. This drastically reduces memory usage when working with large files, especially when performing small concurrent range reads on a large file.
A StreamingObject type has been added to both the fakestorage and backend packages. This type contains a io.ReadSeekCloser that can be used to access object data.
This change sets the stage for fixing #669 and #397. #669 isn't fixed because it will require re-working of how resumable uploads are stored (though other upload types have been made streaming in this PR). Also, fixing #397 would require changing how initial objects are specified when starting the server, which with this approach would require changing the public API.
Regarding the public API: the server methods for working with objects have been changed to use StreamingObject instead of Object. This is a breaking change. It would be possible to make streaming backward compatible by adding some metadata and methods to Object (to distinguish between streaming and buffered objects), but I went with this approach because it made identifying the code that needed to be updated easier; the compiler pointed out the locations to update instead of needing to track down runtime and test errors. An additional improvement, which is compatible with the backward compatible approach, would be to add an OpenForReading method on Object so callers that are currently responsible for closing objects also explicitly open objects (which would make the responsibility clearer). Anyway, I wanted to get this initial approach up for feedback before putting in additional work.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.