Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cenkalti/backoff
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.0.0
Choose a base ref
...
head repository: cenkalti/backoff
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.0.1
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Dec 20, 2024

  1. add changelog

    cenkalti committed Dec 20, 2024
    Copy the full SHA
    31e2809 View commit details

Commits on Jan 17, 2025

  1. Copy the full SHA
    cb748ee View commit details
Showing with 30 additions and 1 deletion.
  1. +29 −0 CHANGELOG.md
  2. +1 −1 retry.go
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [5.0.0] - 2024-12-19

### Added

- RetryAfterError can be returned from an operation to indicate how long to wait before the next retry.

### Changed

- Retry function now accepts additional options for specifying max number of tries and max elapsed time.
- Retry function now accepts a context.Context.
- Operation function signature changed to return result (any type) and error.

### Removed

- RetryNotify* and RetryWithData functions. Only single Retry function remains.
- Optional arguments from ExponentialBackoff constructor.
- Clock and Timer interfaces.

### Fixed

- The original error is returned from Retry if there's a PermanentError. (#144)
- The Retry function respects the wrapped PermanentError. (#140)
2 changes: 1 addition & 1 deletion retry.go
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ func Retry[T any](ctx context.Context, operation Operation[T], opts ...RetryOpti
}

// Stop retrying if maximum elapsed time exceeded.
if time.Since(startedAt)+next > args.MaxElapsedTime {
if args.MaxElapsedTime > 0 && time.Since(startedAt)+next > args.MaxElapsedTime {
return res, err
}