Move the NodeStream server to internal/stream#271
Closed
Conversation
Contributor
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| Go | Feb 24, 2026 7:14p.m. | Review ↗ | |
| Shell | Feb 24, 2026 7:14p.m. | Review ↗ |
Base automatically changed from
meling/268/move-channel-to-stream-pkg
to
master
February 21, 2026 17:02
Extract the gRPC NodeStream implementation from the gorums package into a new internal/stream.Server type, keeping only the public API surface (Server, ServerCtx, Interceptor, Handler) in the gorums package. Introduce a MessageHandler callback type in the stream package so that NodeStream can remain decoupled from gorums.Message. The gorums package wires this callback in RegisterHandler: it creates the ServerCtx, unmarshals the request, wraps it in a gorums.Message, runs the interceptor chain, and dispatches the response — all without the stream package needing to know about gorums-level types. stream/server.go adds: - Server struct (implements GorumsServer via NodeStream) - MessageHandler callback type - NewServer(), RegisterHandler() server.go removes: - streamServer struct, newStreamServer(), NodeStream() (~80 lines) - gorums.Server.srv changes from *streamServer to *stream.Server - RegisterHandler now injects the gorums.Message wrapping callback
ea6ac9e to
38e105c
Compare
Member
Author
|
Superseded by #278 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move
NodeStreamhandler tointernal/streamMotivation
As part of the ongoing refactor to consolidate stream infrastructure in
internal/stream, this PR moves the gRPCNodeStreamimplementation outof the top-level
gorumspackage and into a newinternal/stream.Servertype.
Changes
New file:
internal/stream/server.goIntroduces
stream.Server, which implements the gRPCGorumsServerinterface. It owns the per-connection receive/send loop and mutex-based
request ordering, and dispatches each incoming message to a registered
MessageHandlercallback:The callback design decouples
NodeStreamfromgorums.Message, keepingthe stream package free of any dependency on gorums-level types.
Modified:
server.gostreamServer,newStreamServer(), andNodeStream().Server.srvchanges from*streamServerto*stream.Server.RegisterHandlerinjects aMessageHandlerclosure that handlesServerCtxcreation, request unmarshaling,gorums.Messagewrapping,interceptor chaining, and response dispatch.
Design
The boundary is a callback:
internal/streamowns the transport loop;gorumsowns the application-layer message handling. This preserves thepublic API (
gorums.Server,gorums.ServerCtx,gorums.Interceptor,gorums.Handler,gorums.Message) with no changes to generated code oruser-facing types.
Testing
All existing tests pass. The two pre-existing failures in
TestChannelEnsureStreamandTestChannelStreamReadyAfterReconnectareunrelated to this change.
Fixes #269