Closed wdbaruni closed 4 days ago
The changes introduce a new method, BackoffDuration
, across several structs and interfaces within the backoff package. This method calculates the backoff duration based on the number of attempts. The existing Backoff
method is refactored to utilize this new method, enhancing code modularity. Test coverage is improved with a new test case for validating the backoff duration. Additionally, mock implementations are updated to support the new method, ensuring that the mocking capabilities align with the interface changes.
File Path | Change Summary |
---|---|
pkg/lib/backoff/exponential.go | Added method BackoffDuration(attempts int) time.Duration to Exponential struct. Refactored Backoff to call BackoffDuration . |
pkg/lib/backoff/exponential_test.go | Added test method TestBackoffDuration to validate backoff duration for various attempts. |
pkg/lib/backoff/mock_backoff.go | Added method BackoffDuration(attempts int) time.Duration to MockBackoff . Updated MockBackoffMockRecorder for new method. Changed attempts type in Backoff method to interface{} . |
pkg/lib/backoff/noop.go | Added method BackoffDuration(attempts int) time.Duration to Noop struct, returning zero duration. |
pkg/lib/backoff/types.go | Added method BackoffDuration(attempts int) time.Duration to Backoff interface. Added import for time package. |
In the land of code where rabbits play,
A new backoff method brightens the day.
With attempts counted, durations now clear,
Our logic is tidy, let’s give a cheer! 🐇✨
No more confusion, just hops in the flow,
Backoff and test, watch our features grow!
Summary by CodeRabbit
Release Notes
New Features
BackoffDuration
method across various backoff strategies, allowing for a more modular and consistent approach to calculating backoff durations based on the number of attempts.Noop
struct to provide a zero duration for backoff attempts, aligning with expected interface behavior.Tests
BackoffDuration
method to ensure accurate duration calculations across different scenarios.Chores
BackoffDuration
method, improving testing capabilities.