-
Notifications
You must be signed in to change notification settings - Fork 25
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
replaced httr one-shot functions with httr::RETRY() #148
Conversation
Codecov Report
@@ Coverage Diff @@
## master #148 +/- ##
==========================================
- Coverage 54.93% 1.29% -53.65%
==========================================
Files 24 24
Lines 1509 1544 +35
==========================================
- Hits 829 20 -809
- Misses 680 1524 +844
Continue to review full report at Codecov.
|
Lovely! Thanks for helping this project and adding the perseverance of Why do you choose to use 403 and 404 for My thinking would be to add other response codes to that list, based on this list of Common Box API errors, but I want to understand your design decision before I do. |
I don't know anything about the Box API specifically, just using Just in case you aren't familiar with
If you'd like me to change the |
No I don't think you need to do anything else, this is already great. I'm going to do some manual test today to see what error messages Box sends get back for the common scenarios (files don't exist, users aren't don't have access) and I can add the other response codes as needed. Thanks for doing this again, I see you all have been busy helping a lot of packages. Stuff like this makes me so so happy to be an R user. |
Just to echo everything @nathancday said: thanks @jameslamb and @chircollab, this is wonderful! |
Hey @ijlyttle I've been exploring the different API status codes and I think we should add some of them to My first idea was an internal functions like this:
Which would then get used like this:
As a way to prevent managing multiple repeats. |
I like the idea! I don't know that This might also be an opportunity to refactor using glue. Perhaps as we touch code that uses For example: paste0(
"https://api.box.com/2.0/files/",
file_id, "/content", "?version=", version_id
) could become: glue::glue("https://api.box.com/2.0/files/{file_id}/content?version={version_id}") Just a thought... |
@ijlyttle a function is a better choice because functions are lazily evaluated in R. If you make something a vector (for example), the code to create that vector will get run when the package is loaded. Package source files (in I like the internal-function-wrapping-a-constant pattern! We do this in LightGBM, for example, so we never have to think about the order that |
Thanks y'all! @jameslamb thanks again for doing this! I'm going to close this PR and merge in the one with the additional commit for the internal function strategy. |
@jameslamb I had wondered why I had seen that pattern around, but it never clicked until your explanation, thanks! @nathancday Sounds good to me! |
Thanks for for this awesome project!
In this PR, I'd like to propose swapping out calls to
httr::POST()
,httr::GET()
etc. withhttr::RETRY()
. This will make the package more resilient to transient problems like brief network outages or periods where the service(s) it hits are overwhelmed. In my experience, using retry logic almost always improves the user experience with HTTP clients.I'm working on chircollab/chircollab20#1 as part of Chicago R Collab, an R 'unconference' in Chicago.