Add support for user-specified timeout and retry options in the client. #67
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sailthru customer support suggests retrying on transient failures when
talking to sailthru. This adds support to the client library to make
it easy to do so. We retry on connection timeouts and all 5xx
errors. We do not retry on read timeouts since it's not safe for
POSTs, which are not idempotent (it would be ok for GETs, but that's a
TODO for another day).
Test Plan:
I couldn't figure out how to write an automated test for this since
requests hides all the retry logic from us. (I didn't want to mock
the internals of the requests module since I felt that was brittle.)
But I did create a local server with a route that always returns a
500, and supports only GET and not POST (so it gives a 500 for GET and
a 403 for POST). I then did
and looked in the server-logs and saw the
/crash
url was hit 4 times.I then did
and looked in the server-logs and saw the endpoint was only hit 1 time
this time.
I then added a route to my server that waits before it responds, and
did
and timed that it took 5 seconds for this to run.