*: extract PacketAssembler for frame-to-packet assembly#43
*: extract PacketAssembler for frame-to-packet assembly#43shubhamdhama wants to merge 6 commits intostream-multiplexingfrom
Conversation
54baa4d to
2e5ff8e
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors wire handling to separate frame parsing from frame-to-packet assembly by introducing a reusable PacketAssembler in drpcwire. This centralizes assembly invariants and lets both drpcstream.Stream and drpcmanager.Manager assemble packets from frames in a consistent way, while drpcwire.Reader now returns individual frames.
Changes:
drpcwire.Readernow exposesReadFrame(frame parsing only) and tests were updated accordingly.- Added
drpcwire.PacketAssemblerto assemble frames into packets with monotonicity/kind invariants and stream-ID consistency. - Updated
drpcstream.Streamanddrpcmanager.Managerto ingest frames and assemble/route complete packets; expanded test coverage around frame handling.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| drpcwire/reader.go | Convert reader from packet reconstruction to single-frame reads (ReadFrame). |
| drpcwire/reader_test.go | Update tests to validate frame-by-frame reading and buffering behavior. |
| drpcwire/packet_builder.go | Introduce PacketAssembler for reusable frame-to-packet assembly and invariants. |
| drpcstream/stream.go | Replace HandlePacket entrypoint with HandleFrame + internal handlePacket. |
| drpcstream/stream_test.go | Update existing tests for frame handling; add a large suite of HandleFrame tests. |
| drpcmanager/manager.go | Switch manager reader loop to ReadFrame, add invoke-sequence assembly and routing updates. |
| drpcmanager/manager_test.go | Add tests for global monotonicity, invoke sequencing, and frame delivery behavior. |
| drpcconn/conn_test.go | Update conn tests to use ReadFrame for verifying on-wire output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Extract the frame assembly logic from Stream.HandleFrame into a reusable PacketAssembler type in drpcwire. Both the stream and the manager now use their own PacketAssembler instance, keeping assembly logic in one place. The manager's assembler handles the invoke sequence (metadata + invoke), which removes the restriction that only KindMessage packets could be split across frames. This also simplifies NewServerStream from a packet-at-a-time loop into a single receive.
2e5ff8e to
0f1fbbe
Compare
0b8ee3d to
162c5ab
Compare
|
I've moved the invoke packet assembler and metadata from from manageReader to Manager as a field and clearly mentioned that I'm think we may move manageReader to its own struct. |
Rename packet_builder.go to packet_assembler.go for clarity. Move frame-to-packet assembly tests from drpcstream/stream_test.go to drpcwire/packet_assembler_test.go, testing PacketAssembler directly without Stream dependencies. Stream tests now focus on handlePacket behavior (delivery, termination, invoke rejection).
04265e8 to
6ea6efb
Compare
Extract the frame assembly logic from Stream.HandleFrame into a
reusable PacketAssembler type in drpcwire. Both the stream and the
manager now use their own PacketAssembler instance, keeping assembly
logic in one place.
The manager's assembler handles the invoke sequence (metadata +
invoke), which removes the restriction that only KindMessage packets
could be split across frames. This also simplifies NewServerStream
from a packet-at-a-time loop into a single receive.