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

Add DoInAttemptWithDelay and DoInAttempt functions #450

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marktimarev
Copy link

@marktimarev marktimarev commented May 11, 2024

The Attempt like functions are awesome and help a lot with operations prone to fail, i.e. networking stuff.

Nevertheless, only procedure implementation is available in the library. So, it forced me to use constructions like the following:

fooOut, err := func() (FooOut, error) {
	var fooOut FooOut
	var err error
	_, _ = Attempt(10, func(_ int) error {
		fooOut, err = foo()
		return err
	})
	return fooOut, err
}()

I ended up doing this stuff so often, so I decided to contribute if you do not mind :)

@samber
Copy link
Owner

samber commented Jun 28, 2024

Why not just implement Attempt0, Attempt1, Attempt2 ... AttemptX ?

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.

2 participants