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

is there any reason for retries not to be configured per request? #315

Closed
renathoaz opened this issue Feb 27, 2020 · 4 comments · Fixed by #436
Closed

is there any reason for retries not to be configured per request? #315

renathoaz opened this issue Feb 27, 2020 · 4 comments · Fixed by #436
Labels
enhancement v2 For resty v2

Comments

@renathoaz
Copy link

Hi there,
I noticed that retries are configured per client,
is there any reason not to be per request?

Should I always create a new client each time I want to change RetryCount, RetryMaxWaitTime or RetryCondition without affecting one another if it runs concurrently?

For example:

defaultClient := resty.New()


func One() error{
client.
   defaultClient.SetRetryCount(3).SetRetryMaxWaitTime(20 * time.Second)
   defaultClient.R().Post........
}

func Two() error{
client.
   defaultClient.SetRetryCount(5).SetRetryMaxWaitTime(10* time.Second)
   defaultClient.R().Post........
}

in that case I should create a new instance for each function, right ?

@renathoaz renathoaz changed the title Should I create a new for is there any reason for retries not to be configured per request? Feb 27, 2020
@jeevatkm
Copy link
Member

jeevatkm commented Mar 2, 2020

@renathoaz Thanks for reaching out.

Retries are usually gets configured at the client level. E.g.: let's say the application needs to integrate with two services. Then typically people create two dedicated client instances with appropriate settings for each service of nature and thrid one they will create for general usage.

Begin said that technically it is possible to add new enhancement for Retries that collect the following values which override the client level values-

RetryCount
RetryWaitTime
RetryMaxWaitTime
RetryConditions

@renathoaz
Copy link
Author

I got it. maybe not worth the effort. Thank you for the excellent project.

@jeevatkm jeevatkm self-assigned this May 11, 2020
@jeevatkm jeevatkm added the v2 For resty v2 label May 11, 2020
@jeevatkm
Copy link
Member

jeevatkm commented Sep 12, 2021

@renathoaz I thought to inform. RetryConditions at the request level enhancement PR #436 got submittedby @rohitkg98. Will close this one after the merge.

@aadog
Copy link

aadog commented Aug 24, 2022

@雷纳索斯 I implemented session pattern, you can use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement v2 For resty v2
Development

Successfully merging a pull request may close this issue.

3 participants