Skip to content
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

feat: Contextual Stream handling, Goroutine Leak Prevention #49

Merged
merged 5 commits into from
Sep 8, 2024

Conversation

ShivanshVij
Copy link
Member

@ShivanshVij ShivanshVij commented Sep 8, 2024

This PR makes 2 major changes.

First, it guarantees that shutting down the server will wait until all stream handler goroutines have exited. This is done using a mixture of stream context cancellation, and a waitgroup used specifically for streams.

Second, it extends the stream handler interfaces for all RPC streams to take in a context. This context will be cancelled if the client or server is shut down.

The main thing these two changes mean is that if the context passed into a stream handler is ever cancelled, we fully expect those handler goroutines to exit - otherwise they will block the exiting of the client or server.

This PR cannot be merged until loopholelabs/frisbee-go#179 is merged, and the go.mod is updated to point to the newly released version

SuperManifolds

This comment was marked as duplicate.

SuperManifolds
SuperManifolds previously approved these changes Sep 8, 2024
Copy link
Contributor

@SuperManifolds SuperManifolds left a comment

Choose a reason for hiding this comment

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

LGTM

…in a `CloseChannel` method that returns a channel that will notify when the underlying connection is closed - whether it's on purpose or due to an error.

Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>
…in a `CloseChannel` method that returns a channel that will notify when the underlying connection is closed - whether it's on purpose or due to an error.

Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>
Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>
Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>
Signed-off-by: Shivansh Vij <shivanshvij@outlook.com>
@ShivanshVij ShivanshVij merged commit e4e8578 into main Sep 8, 2024
4 checks passed
@ShivanshVij ShivanshVij deleted the shiv/stream-wg branch September 8, 2024 16:57
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.

2 participants