Skip to content
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

support context cancel cause #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/avast/retry-go/v4

go 1.18
go 1.20

require github.com/stretchr/testify v1.9.0

Expand Down
10 changes: 5 additions & 5 deletions retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
opt(config)
}

if err := config.context.Err(); err != nil {
if err := context.Cause(config.context); err != nil {

Check failure on line 135 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, ubuntu-latest)

undefined: context.Cause

Check failure on line 135 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, ubuntu-latest)

undefined: context.Cause

Check failure on line 135 in retry.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: context.Cause (typecheck)

Check failure on line 135 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, macos-latest)

undefined: context.Cause

Check failure on line 135 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, macos-latest)

undefined: context.Cause

Check failure on line 135 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, windows-latest)

undefined: context.Cause

Check failure on line 135 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, windows-latest)

undefined: context.Cause
return emptyT, err
}

Expand Down Expand Up @@ -161,9 +161,9 @@
case <-config.timer.After(delay(config, n, err)):
case <-config.context.Done():
if config.wrapContextErrorWithLastError {
return emptyT, Error{config.context.Err(), lastErr}
return emptyT, Error{context.Cause(config.context), lastErr}

Check failure on line 164 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, ubuntu-latest)

undefined: context.Cause

Check failure on line 164 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, ubuntu-latest)

undefined: context.Cause

Check failure on line 164 in retry.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: context.Cause (typecheck)

Check failure on line 164 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, macos-latest)

undefined: context.Cause

Check failure on line 164 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, macos-latest)

undefined: context.Cause

Check failure on line 164 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, windows-latest)

undefined: context.Cause

Check failure on line 164 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, windows-latest)

undefined: context.Cause
}
return emptyT, config.context.Err()
return emptyT, context.Cause(config.context)

Check failure on line 166 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, ubuntu-latest)

undefined: context.Cause

Check failure on line 166 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, ubuntu-latest)

undefined: context.Cause

Check failure on line 166 in retry.go

View workflow job for this annotation

GitHub Actions / golangci-lint

undefined: context.Cause (typecheck)

Check failure on line 166 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, macos-latest)

undefined: context.Cause

Check failure on line 166 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, macos-latest)

undefined: context.Cause

Check failure on line 166 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, windows-latest)

undefined: context.Cause

Check failure on line 166 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, windows-latest)

undefined: context.Cause
}
}
}
Expand Down Expand Up @@ -207,10 +207,10 @@
case <-config.timer.After(delay(config, n, err)):
case <-config.context.Done():
if config.lastErrorOnly {
return emptyT, config.context.Err()
return emptyT, context.Cause(config.context)

Check failure on line 210 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, ubuntu-latest)

undefined: context.Cause

Check failure on line 210 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, ubuntu-latest)

undefined: context.Cause

Check failure on line 210 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, macos-latest)

undefined: context.Cause

Check failure on line 210 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, macos-latest)

undefined: context.Cause

Check failure on line 210 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, windows-latest)

undefined: context.Cause

Check failure on line 210 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, windows-latest)

undefined: context.Cause
}

return emptyT, append(errorLog, config.context.Err())
return emptyT, append(errorLog, context.Cause(config.context))

Check failure on line 213 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, ubuntu-latest)

undefined: context.Cause

Check failure on line 213 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, ubuntu-latest)

undefined: context.Cause

Check failure on line 213 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, macos-latest)

undefined: context.Cause

Check failure on line 213 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, macos-latest)

undefined: context.Cause

Check failure on line 213 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.18, windows-latest)

undefined: context.Cause

Check failure on line 213 in retry.go

View workflow job for this annotation

GitHub Actions / tests (1.19, windows-latest)

undefined: context.Cause
}

n++
Expand Down
Loading