-
Notifications
You must be signed in to change notification settings - Fork 1
Description
What is this
We want a simple http client that can send get() and post() requests.
This client must be wrapped with the python backoff library so it will retry where a request fails.
What to do
- Set a default backoff maximum of 30 seconds, but allow that to be configured by a kwarg.
- When a request fails, log out the cause for failure and the retry number if its feasible without turning the codebase into spagetti (i.e log out how many times we've backed off).
- Propogate args and kwargs, something like:
def get(url, *args, **kwargs):
return requests.get(url, *args, **kwargs)
i.e we don't want to lockdown request with a strict function signature as we don't know the requirmeents of the services using this so want to allow devs to pass through anything they'd usually pass through to requests.
Note when you're propogating kwargs you need to make sure to keep your own methods kwargs separate from the the ones you're passing through so (1) whatever kwarg you use for timeout, make sure its not used by requests and (2) pop it from the kwargs dict (if its in there) and make use of it before passing **kwargs to request, just dont pass it through to requests without sorting that out otherwise you'll get errors and/or unexpected behaviour.
Acceptance Criteria
- get and post methods implemented.
- exponential backoff implemented.
- test coverage for (a) methods (b) backoff and (c) proprogate kwargs (just pick a header or something you'd sometimes pass to request and confirm its getting passed through).