8000 Don't error on cancelled startup to make it not necessary to export `ErrShutdown` by brandur · Pull Request #841 · riverqueue/river · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Don't error on cancelled startup to make it not necessary to export ErrShutdown #841

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

Merged
merged 1 commit into from
Apr 9, 2025

Conversation

brandur
Copy link
Contributor
@brandur brandur commented Apr 9, 2025

This change's driven by the proposal in #830. When client start up is
cancelled by a stop, we'd return ErrShutdown as a special signal. The
problem is that ErrShutdown was never exported, so this wasn't really
usable by outside callers.

In #830 it was proposed to export ErrShutdown. However, after some
discussion, we suspect that it might be better to leave it unexported,
and then have Start return no error on cancelled startup. This
minimizes the number of startup conditions callers have to handle.

Because ErrShutdown wasn't previously exported, we should be able to
make this change safely without breaking anyone.

@mastercactapus did bring up a fair point that the alternative of
exporting ErrShutdown would allow a caller to definitively tell the
difference between the client successfully starting and backgrounding
itself versus one whose start was cancelled. I think we're okay not to
require that differentiation though because if ErrShutdown would've be
returned, then the caller would have called Stop, so presumably they'd
know to expect an successful start.

I figure that in case a strong case for wanting to differentiate the
cases comes through, we could always resurrect the error.

Also, rename the internal ErrShutdown to ErrStop to be more
consistent with the naming of Client.Stop (which had previously been
called Shutdown). This won't make any difference, but will be a little
better in case we ever do export it and then forget to rename it at that
time.

…ErrShutdown`

This change's driven by the proposal in #830. When client start up is
cancelled by a stop, we'd return `ErrShutdown` as a special signal. The
problem is that `ErrShutdown` was never exported, so this wasn't really
usable by outside callers.

In #830 it was proposed to export `ErrShutdown`. However, after some
discussion, we suspect that it might be better to leave it unexported,
and then have `Start` return no error on cancelled startup. This
minimizes the number of startup conditions callers have to handle.

Because `ErrShutdown` wasn't previously exported, we should be able to
make this change safely without breaking anyone.

@mastercactapus did bring up a fair point that the alternative of
exporting `ErrShutdown` would allow a caller to definitively tell the
difference between the client successfully starting and backgrounding
itself versus one whose start was cancelled. I think we're okay not to
require that differentiation though because if `ErrShutdown` would've be
returned, then the caller would have called `Stop`, so presumably they'd
know to expect an successful start.

I figure that in case a strong case for wanting to differentiate the
cases comes through, we could always resurrect the error.

Also, rename the internal `ErrShutdown` to `ErrStop` to be more
consistent with the naming of `Client.Stop` (which had previously been
called `Shutdown`). This won't make any difference, but will be a little
better in case we ever do export it and then forget to rename it at that
time.
@brandur brandur force-pushed the brandur-no-error-on-cancelled-start branch from f6470c0 to 38c731e Compare April 9, 2025 07:30
@brandur
Copy link
Contributor Author
brandur commented Apr 9, 2025

Thx.

@brandur brandur merged commit c2fbaa4 into master Apr 9, 2025
10 checks passed
7113
@brandur brandur deleted the brandur-no-error-on-cancelled-start branch April 9, 2025 14:39
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
0