Skip to content

*: use per-stream Finished signal instead of shared sfin channel#45

Open
shubhamdhama wants to merge 1 commit intoshubham/simplify-manageStreamsfrom
shubham/use-stream-finished
Open

*: use per-stream Finished signal instead of shared sfin channel#45
shubhamdhama wants to merge 1 commit intoshubham/simplify-manageStreamsfrom
shubham/use-stream-finished

Conversation

@shubhamdhama
Copy link
Copy Markdown

Replace the shared sfin channel with stream.Finished(), giving each
stream its own completion signal. The shared channel worked for
single-stream-at-a-time. Per-stream signals are required for
multiplexing where multiple streams finish independently.

@shubhamdhama shubhamdhama force-pushed the shubham/simplify-manageStreams branch from 2b7433e to cf11131 Compare March 30, 2026 14:07
@shubhamdhama shubhamdhama force-pushed the shubham/use-stream-finished branch from 779b184 to 341397a Compare March 30, 2026 14:07
Replace the shared sfin channel with stream.Finished(), giving each
stream its own completion signal. The shared channel worked for
single-stream-at-a-time. Per-stream signals are required for
multiplexing where multiple streams finish independently.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates stream completion signaling to use the per-stream (*drpcstream.Stream).Finished() channel rather than a single shared “stream finished” channel, which is necessary for correct behavior when multiple streams can complete independently (multiplexing).

Changes:

  • Removed the shared sfin channel from drpcmanager.Manager and switched waiting logic to stream.Finished().
  • Removed fin plumbing from drpcstream.Stream construction and finish-path signaling.
  • Deleted GetStreamFin/SetStreamFin from internal stream options.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
internal/drpcopts/stream.go Removes accessors for the old shared finish channel in internal stream options.
drpcstream/stream.go Removes the stream-level fin channel and stops emitting to a shared finished notifier.
drpcmanager/manager.go Replaces waits on the shared sfin channel with waits on stream.Finished().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 20 to 28
// GetStreamTransport returns the drpc.Transport stored in the options.
func GetStreamTransport(opts *Stream) drpc.Transport { return opts.transport }

// SetStreamTransport sets the drpc.Transport stored in the options.
func SetStreamTransport(opts *Stream, tr drpc.Transport) { opts.transport = tr }

// GetStreamFin returns the chan<- struct{} stored in the options.
func GetStreamFin(opts *Stream) chan<- struct{} { return opts.fin }

// SetStreamFin sets the chan<- struct{} stored in the options.
func SetStreamFin(opts *Stream, fin chan<- struct{}) { opts.fin = fin }

// GetStreamKind returns the StreamKind stored in the options.
func GetStreamKind(opts *Stream) drpc.StreamKind { return opts.kind }

Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After removing GetStreamFin/SetStreamFin, the underlying fin chan<- struct{} field still remains in drpcopts.Stream (see internal/drpcopts/stream.go:14) but is now unreachable outside the package and has no remaining references in the repo. Consider deleting the fin field from drpcopts.Stream to avoid dead/unused internal state and confusion about how stream completion is signaled (now via (*drpcstream.Stream).Finished()).

Copilot uses AI. Check for mistakes.
@cthumuluru-crdb
Copy link
Copy Markdown

I don't believe this change is needed in mux world? The only reason s.fin is to signal that the active stream is complete and a new stream can be started but in mux world, we can have more than one streams active at any point of time. Its probably better you drop the use of sfin entirely.

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.

3 participants