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

Retrier called even with 0 retry count #89

Open
sunjayaali opened this issue Aug 12, 2020 · 1 comment · May be fixed by #94
Open

Retrier called even with 0 retry count #89

sunjayaali opened this issue Aug 12, 2020 · 1 comment · May be fixed by #94

Comments

@sunjayaali
Copy link

  server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		w.WriteHeader(500)
	}))
	defer server.Close()

	retryCalled := 0
	httpclient := httpclient.NewClient(
		httpclient.WithRetrier(heimdall.NewRetrierFunc(func(_ int) time.Duration {
			retryCalled++
			return 1 * time.Second
		})),
		httpclient.WithRetryCount(0),
	)
	req, err := http.NewRequest(http.MethodGet, server.URL, nil)
	assert.NoError(t, err)
	res, err := httpclient.Do(req)
	assert.NoError(t, err)
	_ = res
	assert.Equal(t, 0, retryCalled)

retrier still called with 0 retry count, is this expected?

@vthiery
Copy link
Contributor

vthiery commented Aug 18, 2020

Another problem that is linked is that time.Sleep(backoffTime) will be called even when the retries are exhausted, which can lead to quite a waste of time for the caller.

If we agree on both these issues, I'd be happy to propose a fix.

greut added a commit to greut/heimdall that referenced this issue Sep 16, 2020
Signed-off-by: Yoan Blanc <yblanc@edgelab.ch>
@greut greut linked a pull request Sep 16, 2020 that will close this issue
greut added a commit to greut/heimdall that referenced this issue Sep 16, 2020
Signed-off-by: Yoan Blanc <yblanc@edgelab.ch>
Panlq pushed a commit to Panlq/heimdall that referenced this issue Apr 6, 2022
…nd tiem sleep will be called even when the retries are exhausted
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.

2 participants