Skip to content

Move Channel implementation to internal/stream#270

Open
meling wants to merge 1 commit intomasterfrom
meling/268/move-channel-to-stream-pkg
Open

Move Channel implementation to internal/stream#270
meling wants to merge 1 commit intomasterfrom
meling/268/move-channel-to-stream-pkg

Conversation

@meling
Copy link
Member

@meling meling commented Feb 13, 2026

Fixes #268

This change moves the core stream management logic from the gorums package into a new internal/stream package to improve encapsulation and testability.

Key changes:

  • Moved channel.go to internal/stream containing Channel, Request, and Message types along with their associated logic.
  • Channel now encapsulates the grpc.ClientStream lifecycle, handling connection establishment, reconnection, and message routing.
  • The Node struct delegates underlying communication and metrics (Latency, LastErr) to Channel.
  • Refactored sender and receiver loops in Channel for better robustness and to properly drain the send queue on closure, fixing potential deadlocks.

This commit moves the core stream management logic from the `gorums`
package into a new `internal/stream` package to improve encapsulation
and testability.

Key changes:
- Moved channel.go to `internal/stream` containing `Channel`, `Request`,
  and `Message` types along with their associated logic.
- `Channel` now encapsulates the `grpc.ClientStream` lifecycle,
  handling connection establishment, reconnection, and message routing.
- The `Node` struct delegates underlying communication and metrics
  (Latency, LastErr) to `Channel`.
- Refactored `sender` and `receiver` loops in `Channel` for better
  robustness and to properly drain the send queue on closure, fixing
  potential deadlocks.
- Updated `channel_test.go` with robust, table-driven tests covering
  connection states, context cancellation, and concurrent sends.
- Added benchmarks for channel performance and stream reconnection.
@deepsource-io
Copy link
Contributor

deepsource-io bot commented Feb 13, 2026

DeepSource Code Review

DeepSource reviewed changes in the commit range 5deecbd..6359fde on this pull request. Below is the summary for the review, and you can see the individual issues we found as review comments.

For detailed review results, please see the PR on DeepSource ↗

PR Report Card

Security × 1 issue Overall PR Quality   

Focus Area: Security

Guidance
Address the possible insecure gRPC server in `internal/stream/channel_test.go` detected by `grpc.NewServer(opts...)`.
Reliability × 0 issues
Complexity × 0 issues
Hygiene × 0 issues

Code Review Summary

Analyzer Status Summary Details
Go 1 new issue detected. Review ↗
Shell No new issues detected. Review ↗
How are these analyzer statuses calculated?

Administrators can configure which issue categories are reported and cause analysis to be marked as failed when detected. This helps prevent bad and insecure code from being introduced in the codebase. If you're an administrator, you can modify this in the repository's settings.

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.

chore: move more of the stream implementation from the root-level gorums package to the stream package

1 participant