-
Notifications
You must be signed in to change notification settings - Fork 93
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
tweak graceful shutdown example to exit after soft shutdown #80
Conversation
@brandur on a related note, prior to release we removed an API on |
Wait ... did this revert the blocks-until-stop semantics of |
The stop methods as of #79 block until shutdown is complete or the user-provided context is cancelled/timed out. I’m fairly sure that’s what #78 was asking for and it seems like the correct behavior to me (what’s the point of that context otherwise, and it simplifies control flow to not have them block on a cancelled context per the shortened examples). Can you elaborate on what more work you’re imagining? My comment above was about the fact that the shutdown examples still need to allocate a channel that’s used to determine when shutdown is complete. River already has such a channel internally so it would simplify usage and shorten these examples if it was re-exposed. |
Talked over Slack, and I think we're roughly on the same page with this. The new channel wouldn't be required per se, but provided to simplify the graceful shutdown code somewhat. After thinking about it a little more, seems okay to me. I'd vote we call a new channel |
This follows some discussion in #80 about how this would be a small improvement because it eliminates the need for users to make their own channel for the same purpose.
This follows some discussion in #80 about how this would be a small improvement because it eliminates the need for users to make their own channel for the same purpose.
This follows some discussion in #80 about how this would be a small improvement because it eliminates the need for users to make their own channel for the same purpose.
As I was updating the docs to account for #79, I realized I had removed the ability for the graceful shutdown example to cleanly exit if the soft shutdown succeeded. It never will succeed in this example, but for users following the code it seems worth accounting for it with the flow.
This gets a little wonky with the logic and the structuring in a single goroutine, but I think this is correct:
nil
error, return immediately because that means shutdown was successful.