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

Retries #31

Closed
maelle opened this issue Apr 12, 2018 · 10 comments
Closed

Retries #31

maelle opened this issue Apr 12, 2018 · 10 comments
Labels
Milestone

Comments

@maelle
Copy link
Member

maelle commented Apr 12, 2018

Related to #4 (comment)

How would one test for the case when the API returns 429 say 3 times and then 200? How could I stub that in a test?

@sckott
Copy link
Collaborator

sckott commented Apr 12, 2018

Thanks for raising the issue!

We don't support it yet. There's two things we need i think.

@maelle
Copy link
Member Author

maelle commented Apr 12, 2018

cool, am excited for it to be supported in the future! should I close this issue or let it open to remember to write an example or something?

@sckott sckott mentioned this issue Apr 12, 2018
2 tasks
@sckott
Copy link
Collaborator

sckott commented Apr 12, 2018

can leave it open i think for now, will label it a use case, then we can include as an example

@maelle
Copy link
Member Author

maelle commented Feb 26, 2020

Re-visiting ropenaq tests, I'm very interested in this.

@sckott
Copy link
Collaborator

sckott commented Feb 26, 2020

okay, will bump this up in the priority list

@maelle
Copy link
Member Author

maelle commented Mar 29, 2020

When this works won't it be easier to test the "retry" method in crul? 🙂

@sckott
Copy link
Collaborator

sckott commented Mar 29, 2020

yes, good point

@sckott sckott added this to the v0.7 milestone Apr 8, 2020
@sckott
Copy link
Collaborator

sckott commented Apr 8, 2020

@maelle okay, we have support for multiple responses now - the then branch is now merged to master. something like:

library(webmockr)
enable()

stub_request("get", "https://httpbin.org/get") %>% 
  to_return(status = 429, body = "retry!", times = 3) %>% 
  to_return(status = 200, body = "yay, success!")

res <- crul::HttpClient$new("https://httpbin.org/get")$retry("get", verbose = TRUE)
res$parse("UTF-8")

@maelle
Copy link
Member Author

maelle commented Apr 9, 2020

That's really nice. I was thinking about using this for ropenaq tests but in ropenaq I use the crul retry method for non async and hope that there will be a crul retry method for async. This way no need for me to test for that in ropenaq... I'll try to make a PR to add a test to crul.

@maelle
Copy link
Member Author

maelle commented Apr 9, 2020

mmmh actually I also add a test to ropenaq. ropensci-archive/ropenaq#55

@sckott sckott closed this as completed Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants