Repository navigation
Add Fusion Transport Layer - #8410
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds foundational transport abstractions and integrates them into existing HTTP and WebSocket transports, while replacing legacy buffer helpers with a unified pooled writer approach across the codebase. Key changes include:
- Refactored low-level buffering: removed
BufferHelper, updatedPooledArrayWriterto implementIMemoryOwner<byte>withWrittenMemory/WrittenSpan, and introducedPooledArrayWriterMarshalandJsonDocumentOwner. - Switched all direct calls from
GetWrittenMemory/GetWrittenSpanto the new properties, and updated JSON parsing/formatting accordingly. - Consolidated context data keys by replacing many usages of
WellKnownContextDatawithExecutionContextData.
Reviewed Changes
Copilot reviewed 175 out of 234 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/HotChocolate/Utilities/src/Utilities/BufferHelper.cs | Removed; streaming logic now uses PooledArrayWriter directly. |
| src/HotChocolate/Utilities/src/Utilities.Buffers/PooledArrayWriter.cs | Changed to implement IMemoryOwner<byte>, added WrittenMemory/WrittenSpan, and removed legacy methods. |
| src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Execution/FusionRequestExecutorManager.cs | Added channel-based observer pattern for executor creation/eviction and a file-scoped extensions helper. |
| src/HotChocolate/Fusion-vnext/test/Fusion.AspNetCore.Tests/Extensions/ServiceCollectionExtensions.cs | Introduced a custom AddHttpClient extension to wire TestServer into IHttpClientFactory for tests. |
Files not reviewed (1)
- src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Properties/AspNetCorePipelineResources.Designer.cs: Language not supported
Comments suppressed due to low confidence (2)
src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Execution/Pipeline/OperationVariableCoercionMiddleware.cs:44
- Changing
TryCoerceVariablesfrom public to private restricts its accessibility and may break callers who rely on it; consider preserving its public API surface or updating all references.
private static bool TryCoerceVariables(
src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Execution/FusionRequestExecutorManager.cs:589
- [nitpick] The class name
Extensionsis very generic and could clash with other extension-method classes; consider renaming it to something more descriptive.
file static class Extensions
| const int chunkSize = 256; | ||
| await using var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read); | ||
| using var writer = new PooledArrayWriter(); | ||
| var read = 0; | ||
|
|
||
| var document = await BufferHelper.ReadAsync( | ||
| stream, | ||
| static (buffer, buffered) => | ||
| { | ||
| var span = buffer.AsSpan()[..buffered]; | ||
| return Utf8GraphQLParser.Parse(span); | ||
| }, | ||
| cancellationToken) | ||
| .ConfigureAwait(false); | ||
| do | ||
| { | ||
| var memory = writer.GetMemory(chunkSize); | ||
| read = await stream.ReadAsync(memory, cancellationToken).ConfigureAwait(false); | ||
| writer.Advance(read); | ||
| } while (read == chunkSize); |
There was a problem hiding this comment.
[nitpick] Using a fixed chunk size of 256 bytes may cause many small reads for larger files; consider increasing or making this buffer size configurable to reduce IO overhead.
Uh oh!
There was an error while loading. Please reload this page.