feat: Add LastRequestExecuting event for resumable uploads - #2
feat: Add LastRequestExecuting event for resumable uploads#2mahendra-google wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new LastRequestExecuting event to the ResumableUpload class, which is triggered when the final chunk of data is uploading. It also adds corresponding unit tests to verify the event's behavior in both single-chunk and multi-chunk upload scenarios. The review feedback suggests correcting a minor grammatical typo in the event's XML documentation and splitting two statements onto separate lines in the multi-chunk test file to improve readability.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| /// <summary> | ||
| /// Event called when the final chunk of a data is uploading. | ||
| /// </summary> |
| using (var service = new MockClientService(server.HttpPrefix)) | ||
| { | ||
| var content = knownSize ? new MemoryStream(UploadTestBytes) : new UnknownSizeMemoryStream(UploadTestBytes); | ||
| var uploader = new TestResumableUpload(service, "MultiChunk", "POST", content, "text/plain", chunkSize); int eventInvokeCount = 0; |
There was a problem hiding this comment.
For better readability and adherence to standard C# coding conventions, avoid placing multiple statements on a single line. Please split the uploader initialization and the eventInvokeCount declaration into separate lines.
var uploader = new TestResumableUpload(service, "MultiChunk", "POST", content, "text/plain", chunkSize);
int eventInvokeCount = 0;|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new LastRequestExecuting event to ResumableUpload, which fires when the final chunk of data is being uploaded. It also adds comprehensive unit tests to verify this event's behavior across single-chunk, multi-chunk, HTTP retry, and protocol retry scenarios. The feedback suggests a minor improvement in one of the new tests to replace an unnecessary single-iteration loop with a direct assertion, which will improve code readability.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| for (int i = 0; i < 1; i++) | ||
| { | ||
| Assert.Equal("MyToken", server.ReceivedCustomHeaders[i]); | ||
| } |
There was a problem hiding this comment.
The for loop here is configured to run for exactly one iteration (i < 1), which is unnecessary and reduces code readability. It is cleaner and more direct to assert on the first element of server.ReceivedCustomHeaders directly without a loop.
Assert.Equal("MyToken", server.ReceivedCustomHeaders[0]);|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new LastRequestExecuting event to the ResumableUpload class, which is triggered when the final chunk of data is being uploaded. It also includes comprehensive unit tests for both single-chunk and multi-chunk uploads, verifying that the event fires correctly and that custom headers are preserved during HTTP and protocol retries. There are no review comments, and I have no additional feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
188637f to
ff35b35
Compare
This PR introduces the
LastRequestExecutingevent to theResumableUploadclass , providing capability to modify theHttpRequestMessageright before the final upload chunk is uploaded to the server.This capability is essential for client libraries (such as
Google.Cloud.Storage.V1) that need to attach server-side validation headers (e.g.,x-goog-hash: crc32c=...) on the final chunk of a resumable upload.