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: context-managed streams #179

Merged
merged 3 commits into from
Sep 8, 2024
Merged

feat: context-managed streams #179

merged 3 commits into from
Sep 8, 2024

Conversation

ShivanshVij
Copy link
Member

@ShivanshVij ShivanshVij commented Sep 8, 2024

This PR creates some very breaking changes, but brings the overall implementation of the frisbee client and server inline with what one would expect, while filling some gaps in our implementation with regards to thread safety.

The firs thing this PR does is modifies stream management within the context of a server or client to properly make use of the base context for a server or client when handling new streams - this means the SetStreamHandler functions of both the client and the server now accept a context. This context will also now automatically be cancelled if the client or server is closed (or if the underlying client connection is ever closed).

This PR also adds a new StreamContext option that allows user to override how contexts for streams get created, as well as what values they contain.

The main breaking change this PR makes is it removes the BaseContext function in the server, and instead sets a static baseContext context that the user can pass in at runtime. This context is used to cancel handler goroutines and not used to kill the server or client itself.

What's important to note is that this change is necessary if we want the death of a client or server to also cancel the context.

…to properly make use of contexts.

Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>
Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>
…lient does.

Signed-off-by: Shivansh Vij <shivanshvij@loopholelabs.io>
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

@ShivanshVij ShivanshVij merged commit 6e1bae7 into main Sep 8, 2024
5 checks passed
@ShivanshVij ShivanshVij deleted the shiv/stream-contexT branch September 8, 2024 16:53
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