-
Notifications
You must be signed in to change notification settings - Fork 446
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
Feature/streaming jsonrpc batch request #5134
Conversation
…e/streaming-jsonrpc-batch-request
{ | ||
if (result.IsCollection) | ||
await using MemoryStream resultData = new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we are doing such a great job already, maybe we can drop this allocation too? To some reused buffer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do in next PR though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My ideas are to implement either Stream
or TextWriter
based on IByteBuffer
and use PooledByteBufferAllocator
…request' into feature/streaming-jsonrpc-batch-request
await _handler.SendRawAsync(_jsonOpeningBracket); | ||
await foreach (JsonRpcResult.Entry innerResult in result.BatchedResponses!) | ||
{ | ||
if (!isFirst) await _handler.SendRawAsync(_jsonComma); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we dig deeper, we find:
- In
IpcSocketsHandler
,_socket.SendAsync(data, SocketFlags.None)
, not sure if we should setSocketFlags.Truncated
orSocketFlags.Partial
until we send_jsonClosingBracket
. - In
WebSocketHandler
we have_webSocket.SendAsync(data, WebSocketMessageType.Text, true, CancellationToken.None)
, maybe we should setendOfMessage
tofalse
until we send_jsonClosingBracket
.
* Refactor to use a single batched collection * Using another jsonrpc response * Make unit test compile * So now trying enumerable * Fix test compilation * some refactor * fix test * Fix test * Fix whitespace * tiny improvements * Second time I missed this exact same bug * Fix may break websocket Co-authored-by: lukasz.rozmej <lukasz.rozmej@gmail.com>
* Refactor to use a single batched collection * Using another jsonrpc response * Make unit test compile * So now trying enumerable * Fix test compilation * some refactor * fix test * Fix test * Fix whitespace * tiny improvements * Second time I missed this exact same bug * Fix may break websocket Co-authored-by: lukasz.rozmej <lukasz.rozmej@gmail.com>
* Refactor to use a single batched collection * Using another jsonrpc response * Make unit test compile * So now trying enumerable * Fix test compilation * some refactor * fix test * Fix test * Fix whitespace * tiny improvements * Second time I missed this exact same bug * Fix may break websocket Co-authored-by: lukasz.rozmej <lukasz.rozmej@gmail.com>
Changes
IEnumerable
ofJsonRpcResult.Entry
, allowing lazy and streaming processing of batched reuest.Types of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?
Notes on testing