Add context timeout/deadline causes #5043
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
internal/event: simplify new ctx creation
If the input context is done, we construct a new context
with a new timeout. Make use of context.WithoutCancel
to simplify the logic for adding existing context values
into this new context.
internal/errors: add ctx cancel cause
Adds the context cancel cause to the error, if set. This can
provide useful error information to debugging efforts
when a context cancellation error happens.
internal/event: include context cancel cause in event
The context cancel cause can be a great way to understand
why a context was canceled.
all: add cancellation causes to timeouts
The new WithTimeoutCause and WithDeadlineCause functions
allow us to decorate contexts with metadata surrounding
a specific timeout or deadline. Combined with the automatic
discovery of the context cause in the errors and event
packages, we should get much more information about
context cancellations.
internal/daemon: simplify time update tests
Using time.After makes the intent clearer