Skip to content

refactor(git): stream bundles from temp files instead of buffering in memory#202

Draft
worstell wants to merge 1 commit intomainfrom
worstell/stream-bundle-files
Draft

refactor(git): stream bundles from temp files instead of buffering in memory#202
worstell wants to merge 1 commit intomainfrom
worstell/stream-bundle-files

Conversation

@worstell
Copy link
Contributor

Summary

createBundle now returns an open *os.File (already unlinked from the filesystem) instead of reading the entire bundle into a []byte. Callers stream directly from the fd and use io.MultiWriter to write to the HTTP response and S3 cache simultaneously.

Changes

  • createBundle: returns *os.File instead of []byte. The temp file is removed from the filesystem immediately after opening; the open fd keeps the data alive until the caller closes it.
  • handleBundleRequest: streams from the file to both the HTTP response and S3 cache via io.MultiWriter, replacing the previous write-then-cache-async pattern.
  • serveSnapshotWithBundle: background goroutine streams from the file to S3 cache.
  • Removed cacheBundleAsync/cacheBundleSync, replaced with single cacheBundle(ctx, key, io.Reader).
  • Removed strconv import (no longer needed without Content-Length header on bundles).

… memory

createBundle now returns an open *os.File (already unlinked from the
filesystem) instead of reading the entire bundle into a []byte. Callers
stream directly from the fd and use io.MultiWriter to write to the HTTP
response and S3 cache simultaneously.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d0383-345f-7659-8538-30bc7c9a7e6d
@worstell worstell requested a review from a team as a code owner March 20, 2026 00:36
@worstell worstell requested review from inez and removed request for a team March 20, 2026 00:36
@worstell worstell marked this pull request as draft March 20, 2026 00:54
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.

1 participant