I sometimes noticed that my SDK calls on my computer periodically interrupted with a 500 error, retrying the request usually fixes the error immediately. Looking at the Google documentation, it is recommended to use an exponential return technique, I wrote my own implementation that works fine, however, during debugging, I accidentally ran into the BackOffPolicy interface, with a lot of research, I even found an implementation of ExponentialBackOffPolicy.
So instead of managing it myself, I decided to better remove my implementation and let the SDK do it for me. The delay policy (according to my information) can be configured using the built-in HTTP request, so it is quite easy to use it when creating requests manually or when using batch requests, however I cannot find the easiest place to enter this value when using the main SDK, for example if I want to set a deferral policy for:
drive.files().get(id).execute();
I can not do something like:
drive.files().get(id) .setBackOffPolicy(new ExponentialBackOffPolicy()) .execute();
I would need to do this:
drive.files().get(id) .buildHttpRequest() .setBackOffPolicy(new ExponentialBackOffPolicy()) .execute();
However, if I do this, I will also need to reproduce the syntax logic of the execute method from Drive.Files.Get and convert the result to a File object, which is obviously not an ideal approach. Is there an easier way to “add” this as a whole to the request, or perhaps specify a way to override the default policy for all requests?
If not, maybe this could be introduced in a future version of the Drive SDK?
Thanks David
source share