boundary icon indicating copy to clipboard operation
boundary copied to clipboard

Add context timeout/deadline causes

Open johanbrandhorst opened this issue 1 year ago • 0 comments
trafficstars

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

johanbrandhorst avatar Aug 24 '24 00:08 johanbrandhorst