Add IDataStreamReceiver.SaveToStreamAsync and lower in-memory threshold to 128MB - #718
Merged
Merged
Conversation
Spec for a second Redis pending request queue implementation that uses System.Threading.Timer instead of Task.Delay/DelayWithoutException, plus a static switch on RedisPendingRequestQueueFactory to select between them, wired into unit tests so both variants get coverage. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
10-task plan covering: extracting WatcherAndDisposables to a shared type, adding an IRedisPendingRequestQueueTestControls interface so tests work against either concrete queue, the TimerBasedDelay primitive, Timer-based copies of the queue/heartbeat sender/watcher, the static switch on RedisPendingRequestQueueFactory (plus fixing two existing test helpers that hard-cast to the concrete queue type), and wiring unit tests to run against both implementations. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ld to 128MB Adds SaveToStreamAsync to IDataStreamReceiver so callers can write a DataStream's contents directly into an arbitrary destination stream, not just to a file path. Implemented across all four receivers (InMemoryDataStreamReceiver, TemporaryFileDataStreamReceiver, TemporaryFileStream, DataStreamRehydrationDataDataStreamReceiver), with SaveToAsync refactored to reuse it. Also lowers the threshold at which DataStream.Receiver() switches from buffering in memory to using a temp file from 2GB to 128MB, reducing peak memory usage for moderately large payloads.
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
@claude review |
xwipeoutx
reviewed
Aug 28, 2026
| @@ -0,0 +1,2120 @@ | |||
| # Timer-based Redis Pending Request Queue Implementation Plan | |||
xwipeoutx
reviewed
Aug 28, 2026
xwipeoutx
reviewed
Aug 28, 2026
| #else | ||
| await file.CopyToAsync(destinationStream); | ||
| #endif | ||
| } |
There was a problem hiding this comment.
So if destinationStream is a NFS-backed FileStream, we need to destinationStream.Flush(flushToDisk: true). The caller can do that if they want, I suppose.
xwipeoutx
approved these changes
Aug 28, 2026
xwipeoutx
left a comment
There was a problem hiding this comment.
Approved, a few nitpicks and ... well a comment ... in the comments
LukeButters
enabled auto-merge (squash)
August 28, 2026 04:36
xwipeoutx
approved these changes
Aug 28, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SaveToStreamAsync(Stream, CancellationToken)toIDataStreamReceiver, implemented on all four receivers (InMemoryDataStreamReceiver,TemporaryFileDataStreamReceiver,TemporaryFileStream,DataStreamRehydrationDataDataStreamReceiver), letting callers write aDataStream's contents to any destination stream, not just a file path.SaveToAsyncon each is refactored to reuse it.DataStream.Receiver()'s in-memory vs temp-file threshold from 2GB (int.MaxValue) to 128MB, reducing peak memory usage for moderately large payloads. For normal "the data stream was transferred" cases the DataStream is always written to disk. This will only come into play when custom Pending Request Queues are in use.Test plan
DataStreamReceiverSaveToStreamAsyncFixture— unit tests forSaveToStreamAsyncon each of the four receiver implementations.LocalDataStreamFixturetests asserting the 128MB threshold picksInMemoryDataStreamReceivervsTemporaryFileDataStreamReceiver.dotnet buildclean onHalibut.csprojandHalibut.Tests.csproj.dotnet test— new tests plus existingLocalDataStreamFixture/DataStreamFixtureregression suite all pass (28/28).🤖 Generated with Claude Code