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

Resty retry function does not work in Slack as custom http client #787

Open
rts-gordon opened this issue Apr 10, 2024 · 1 comment
Open

Comments

@rts-gordon
Copy link

My program send message to Slack channel via slack-go, I used a Resty as a custom http client and set it retry 3 times, but the retry function does not work with slack-go.

I changed to another http client retryablehttp, the retry function works well with slack-go.

slack-go code:

// transfor resty.Client to http.Client
httpClient = InitHttpClient().GetClient()
slack.PostWebhookCustomHTTP(url, httpClient, &msg)

Resty httpClient:

func InitHttpClient() *resty.Client {
	return resty.New().
		SetRetryCount(3).
		SetRetryWaitTime(1 * time.Second).
		SetRetryMaxWaitTime(20 * time.Second)
}

I studied retryablehttp code found that StandardClient returns a stdlib *http.Client with a custom Transport, which shims in a *retryablehttp.Client for added retries. But resty.GetClient just return c.httpClient, can resty.GetClient implement the same retry function? thank you.

Versions
Go: v1.22
slack-go/slack: v0.12.5
Resty: v2.12.0
retryablehttp: v0.7.5

@jeevatkm
Copy link
Member

jeevatkm commented May 9, 2024

@rts-gordon Thanks for reaching out. If I recall correctly, resty.GetClient is the underlying Go HTTP client instance returned as-is. The returned client does not accommodate all the Resty feature(s) today.

Can you fork the Resty, add the implementation, and test it? If it works as-is, you could submit a PR. Otherwise, I will consider it part of the v3 design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants