go-resiliency icon indicating copy to clipboard operation
go-resiliency copied to clipboard

Add a SurfaceWorkErrors() opt to the retrier

Open slizco opened this issue 1 year ago • 0 comments

If the retrier encounters a context-related error, such as context.DeadlineExceeded while attempting retries of work(), the context error is returned. This means the actual error from work() never bubbles up. Because the context is often used to enforce a timeout, many callers are likely more interested in the last non-nil error returned by the work() function.

We introduce a WithSurfaceWorkErrors() option to the retrier.Retrier that when used, means the last non-nil work error will be returned even if context-related errors are encountered.

slizco avatar May 07 '24 15:05 slizco