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

Clean up rpc.Conn.receive #473

Merged
merged 5 commits into from
Mar 1, 2023
Merged

Clean up rpc.Conn.receive #473

merged 5 commits into from
Mar 1, 2023

Conversation

lthibault
Copy link
Collaborator

@lthibault lthibault commented Mar 1, 2023

This is a refactor of rpc.Conn for readability. There are no functional changes.

Clean-up is concentrated in two places:

  1. The switch statement in Conn.receive is tidied up by having each case call out to a dedicated "handler" method.
  2. The reader thread is moved into its own task, allowing it to trigger task shutdown on its own. This in turn lets us implement receiver as a simple range loop over a channel.

A follow-up effort will focus on abstracting tasks & connection lifecycle.

@lthibault lthibault requested a review from zenhack March 1, 2023 00:49
@lthibault lthibault self-assigned this Mar 1, 2023
rpc/rpc.go Outdated Show resolved Hide resolved
@zenhack
Copy link
Contributor

zenhack commented Mar 1, 2023

This broadly looks good to me, modulo the one comment about reader().

@lthibault lthibault requested a review from zenhack March 1, 2023 16:29
@lthibault lthibault merged commit c4dac3b into main Mar 1, 2023
@lthibault lthibault deleted the cleanup/refactor-rpc-recv branch March 1, 2023 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants