Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance StreamResponse handling and update dependencies #121

Merged
merged 9 commits into from
Oct 30, 2024

Conversation

stevejgordon
Copy link
Collaborator

Updated ResponseBuilderDefaults to include StreamResponse in SpecialTypes. Refactored SetBodyCoreAsync in DefaultResponseBuilder.cs for readability and removed unnecessary using statements. Modified RequestCoreAsync in HttpWebRequestInvoker.cs and BuildResponseAsync in InMemoryRequestInvoker.cs to handle StreamResponse types with proper disposal. Updated Elastic.Transport.csproj to reference System.Text.Json version 8.0.5.

@stevejgordon stevejgordon requested a review from flobernd October 11, 2024 13:05
@stevejgordon stevejgordon force-pushed the bug/fix-stream-response branch from eab800f to 2300050 Compare October 22, 2024 12:01
@stevejgordon
Copy link
Collaborator Author

Notes from latest changes:

We have now unsealed StreamResponse to allow for derived responses that rely on the stream (such as the potential specialised bulk response for the ingest work.

While testing, I noticed that with DisableDirectStreaming, we didn't dispose of the buffer used by PostData, and I have amended that accordingly.

Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Mpdreamz
Copy link
Member

Sorry about the conflict!

Updated `ResponseBuilderDefaults` to include `StreamResponse` in `SpecialTypes`. Refactored `SetBodyCoreAsync` in `DefaultResponseBuilder.cs` for readability and removed unnecessary `using` statements. Modified `RequestCoreAsync` in `HttpWebRequestInvoker.cs` and `BuildResponseAsync` in `InMemoryRequestInvoker.cs` to handle `StreamResponse` types with proper disposal. Updated `Elastic.Transport.csproj` to reference `System.Text.Json` version `8.0.5`.
Renamed variable from `receive` to `receivedResponse` in `RequestCoreAsync` method across `HttpRequestInvoker.cs` and `HttpWebRequestInvoker.cs` for better clarity. Updated `using` statements accordingly. Added `try-catch` blocks around response handling logic to ensure `receivedResponse` is disposed of properly, preventing resource leaks. Adjusted finalizer in `StreamResponse` to use `receivedResponse.Dispose()`. Properly indented OpenTelemetry attributes setting logic within the `try` block.
Add `LeaveOpen` property to `StreamResponse` and `TransportResponse` classes for flexible stream management.
@stevejgordon stevejgordon force-pushed the bug/fix-stream-response branch from d1c4f20 to 20bcdf2 Compare October 30, 2024 11:47
@stevejgordon stevejgordon merged commit f4c42c8 into main Oct 30, 2024
5 checks passed
@stevejgordon stevejgordon deleted the bug/fix-stream-response branch October 30, 2024 12:06
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.

3 participants