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

Expose RetryAfter value in error #274

Merged
merged 2 commits into from
Nov 28, 2024
Merged

Expose RetryAfter value in error #274

merged 2 commits into from
Nov 28, 2024

Conversation

flimzy
Copy link
Contributor

@flimzy flimzy commented Nov 15, 2024

Related to, and useful along with #273

@Pineapple217
Copy link

IMO the Error type should contain time.Duration instead of time.Time. If the user wants time.Time they can calculate it them self (or add a method to Error to calculate it on the fly if you want it in the lib). Because if you want time.Duration you are just calculating back the value (doing double work). I know its nitpicky but something to think about. Either way I would be happy with this feature.

@flimzy
Copy link
Contributor Author

flimzy commented Nov 16, 2024

IMO the Error type should contain time.Duration instead of time.Time.

That was my initial thought as well. The problem with a time.Duration is that it looses its meaning virtually immediately. If you're doing any sort of batch processing, or anything else that might delay the handling of an error, then that value cannot be relied on any more. By returning a time.Time, we aren't forcing the consumer of this library into any specific error handling behavior or pattern.

@Pineapple217
Copy link

Fair enough, both have their pros and cons but time.Time is probably better fitting for this lib when you put it like that. More intuitive and flexible.

t.Parallel()
const retryAfter = 2

handlers := []http.HandlerFunc{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've actually never thought about using a slice over a set of a funcs like this in a test - but this is quite nice!

@strideynet strideynet merged commit 2a7f41f into zmb3:master Nov 28, 2024
0 of 2 checks passed
@flimzy flimzy deleted the RetryAfter branch November 28, 2024 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants