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

Use typed channels #97

Merged
merged 8 commits into from
Jul 29, 2024
Merged

Use typed channels #97

merged 8 commits into from
Jul 29, 2024

Conversation

webbnh
Copy link
Contributor

@webbnh webbnh commented Jul 26, 2024

Changes introduced with this PR

This is a follow-on to #96: if the channel instances had been properly typed (to wit, as receive-only), it might not have been possible to close them in the first place (since an attempt to close a receive-only channel results in an error), and that might have alleviated some trouble. So, this PR modifies the Client.Execute() interface (and its implementation and subroutines) to declare the receivedSignals parameter as a receive-only channel, so that its usage is clearer.

In the process of producing that change, it became apparent that we no longer need the handleStepComplete() function and the runningSignalReceiveLoops map, so these were removed, as well as the code supporting them.

This PR also includes three other sets of changes:

  • The first picks lint (and fixes some real issues):
    • There were three places where we were using the %w formatting verb outside of the context of a fmt.Errorf() call:
      • one I fixed by changing it to %v; and,
      • two I fixed by factoring out the formatting, since it was being shared with logging.
    • There was a place where we were missing a formatting verb (it was typed as '&s'; I replaced it with %q).
    • And, there were a couple of other, minor lint complaints that I addressed.
  • The second removes an existence check which is unneed post Fix Channel Close Behavior #96.

By contributing to this repository, I agree to the contribution guidelines.

@webbnh webbnh self-assigned this Jul 26, 2024
atp/client.go Outdated Show resolved Hide resolved
atp/client.go Outdated Show resolved Hide resolved
Copy link
Contributor

@jaredoconnell jaredoconnell left a comment

Choose a reason for hiding this comment

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

Looks good. It probably makes sense to address the comments that Dave pointed out.

atp/client.go Outdated Show resolved Hide resolved
@webbnh webbnh force-pushed the use-typed-channels branch from 5597335 to e52a654 Compare July 29, 2024 14:40
Copy link
Contributor

@jaredoconnell jaredoconnell left a comment

Choose a reason for hiding this comment

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

Looks good. I tested it with the engine and there are no new problems.

Copy link

@dbutenhof dbutenhof left a comment

Choose a reason for hiding this comment

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

More simplerest ...

atp/client.go Show resolved Hide resolved
@webbnh webbnh merged commit 1ff05a7 into main Jul 29, 2024
3 checks passed
@webbnh webbnh deleted the use-typed-channels branch July 29, 2024 18:13
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