Refactor error handling and update options for resource testing#5
Merged
Refactor error handling and update options for resource testing#5
Conversation
Contributor
ziflex
commented
Sep 1, 2025
- Introduced new error types: ErrResourceAlreadyRegistered and ErrResourceNotFound.
- Updated the options struct to include multiplier and randomization factor for exponential backoff.
- Modified functions to use the new error types and updated the README with new error descriptions.
- Changed import path for the backoff package to v5.
- Introduced new error types: ErrResourceAlreadyRegistered and ErrResourceNotFound. - Updated the options struct to include multiplier and randomization factor for exponential backoff. - Modified functions to use the new error types and updated the README with new error descriptions. - Changed import path for the backoff package to v5.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors error handling by introducing specific error types and updates the backoff configuration options. The changes improve error specificity and provide more control over exponential backoff behavior.
- Introduced
ErrResourceAlreadyRegisteredandErrResourceNotFounderror types for better error classification - Updated backoff package to v5 and added multiplier/randomization factor configuration options
- Changed
Optionsstruct to privateoptionsand updated all references accordingly
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| errors.go | Added new error types for resource registration conflicts and missing resources |
| options.go | Made options struct private, added multiplier and randomization factor fields with new setter functions |
| registry.go | Updated error handling to use new structured error types with context |
| waitfor.go | Updated backoff package import and applied new configuration options |
| go.mod | Upgraded backoff dependency to v5 |
| waitfor_test.go | Updated test code to use new private options struct |
| options_test.go | Updated tests for private struct and added tests for new options |
| README.md | Added documentation for new error types |
Comments suppressed due to low confidence (2)
waitfor.go:1
- The backoff.Retry function is being called incorrectly. The function signature expects a single error return value, but line 188 returns two values (bool, error). This should be
return rsc.Test(ctx)instead ofreturn err != nil, err.
// Package waitfor provides utilities for testing and waiting for resource availability
waitfor.go:1
- The variable
erron line 191 is undefined in this scope. It should return the result ofbackoff.Retrydirectly:return backoff.Retry(...).
// Package waitfor provides utilities for testing and waiting for resource availability
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.