r-lib / gargle

Infrastructure for calling Google APIs from R, including auth

Home Page:https://gargle.r-lib.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Give the developer a small window of opportunity to know about retries

gadenbuie opened this issue · comments

When working with gargle via a package like googlesheets, failed requests are automatically retried. This is excellent and it means requests almost always make it through.

The downside is that the retries understandably backoff rather aggressively, so the wait time can be quite long, up to 100 seconds by default. In a Shiny app, this can be an eternity of waiting for the end user, and it'd be helpful for the app author to be able to give some feedback on the progress of the request.

The feature request is for gargle to offer some window of opportunity to know that a retry has happened and to run code before the next retry occurs.

Just brainstorming, two potential ways to do this could be:

  1. gargle::request_retry() could execute a callback function, found via an R option, before calling Sys.sleep().
  2. gargle::request_retry() could take inspiration from rlang::check_installed() and signal a known condition with restarts. This would give (admittedly expert) users a chance to run code before returning control to request_retry().

the wait time can be quite long, up to 100 seconds by default

just to clarify this one point, that is specific to the Sheets API, which has very specific per user quotas

It looks like those have changed since I last set up the special case for Sheets retries, so maybe I don't need the 100 seconds thing any more:

https://developers.google.com/sheets/api/limits