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

Any plans for generic retry from 1.18? #58

Closed
pzartem opened this issue Apr 11, 2022 · 5 comments · Fixed by #91
Closed

Any plans for generic retry from 1.18? #58

pzartem opened this issue Apr 11, 2022 · 5 comments · Fixed by #91

Comments

@pzartem
Copy link

pzartem commented Apr 11, 2022

I can implement it if you have any plan idea for it. This may reduce the amount of closure.

type retryableFunc[TRes any] func() (TRes, error)

val, res := retry.Do(......
@JaSei
Copy link
Collaborator

JaSei commented Apr 11, 2022

Hi, I had thoughts about generics - but I only read this article https://planetscale.com/blog/generics-can-make-your-go-code-slower, and that doesn't sound like I want to add generics everywhere without a deeper analysis of value.

Have you please some another example where generic retry helps you?
Thanks

@pzartem
Copy link
Author

pzartem commented Apr 20, 2022

Few issues with generics perf in that article are fixed only in 1.19. Like this

The only one possible benefit with generics I see now is that you don't need an additional closure on result variable. It's not so much to implement it.

Thanks!

@SladeThe
Copy link

1.19 is out. I vote up for this improvement.
Generics can really reduce amount of code around retryable calls.

@JaSei
Copy link
Collaborator

JaSei commented Apr 21, 2023

Please take a look at #91 and tell us what you think.
thank you

@zerkms
Copy link

zerkms commented Jul 20, 2023

It also is important to remember - that this suggestion only helps for functions that return one value. But functions could return 0, or more than 1 of them.

Counter suggestion: instead of changing retry.Do in a non-BC way, to introduce instead retry.Do1, retry.Do2, ... functions each of which returns the corresponding number of return values. Up to 5 should be fine, I guess.

@JaSei JaSei closed this as completed in #91 Aug 4, 2023
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 a pull request may close this issue.

4 participants