-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specify specific cancel cause on shutdown and use it to determine err…
…or logging (#179) Follow up to a discussion [1] in which an additional error log was causing example tests to fail after uses of `log` were replaced with `slog` and no longer suppressed. Here, use `WithCancelCause` to send a specific cancellation error on shutdown, which can be handled specially for instances where we'd only want to log an error under unusual circumstances. [1] #140 (comment)
- Loading branch information
Showing
5 changed files
with
30 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package rivercommon | ||
|
||
import "errors" | ||
|
||
// These constants are made available in rivercommon so that they're accessible | ||
// by internal packages, but the top-level river package re-exports them, and | ||
// all user code must use that set instead. | ||
const ( | ||
MaxAttemptsDefault = 25 | ||
PriorityDefault = 1 | ||
QueueDefault = "default" | ||
) | ||
|
||
// ErrShutdown is a special error injected by the client into its fetch and work | ||
// CancelCauseFuncs when it's stopping. It may be used by components for such | ||
// cases like avoiding logging an error during a normal shutdown procedure. This | ||
// is internal for the time being, but we could also consider exposing it. | ||
var ErrShutdown = errors.New("shutdown initiated") |