Skip to content
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

Backoff revision. #25

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion tap_restaurant365/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

from datetime import timedelta
from http import HTTPStatus
from typing import Any, Callable, Optional
from typing import Any, Callable, Generator
from urllib.parse import parse_qs, urlparse

import backoff
import requests
from dateutil import parser
from singer_sdk.authenticators import BasicAuthenticator
Expand Down Expand Up @@ -115,3 +116,24 @@ def validate_response(self, response: requests.Response) -> None:
):
msg = self.response_error_message(response)
raise FatalAPIError(msg)

def backoff_wait_generator(self) -> Generator[float, None, None]:
"""The wait generator used by the backoff decorator on request failure.

See for options:
https://github.com/litl/backoff/blob/master/backoff/_wait_gen.py

And see for examples: `Code Samples <../code_samples.html#custom-backoff>`_

Returns:
The wait generator
"""
return backoff.expo(factor=5)

def backoff_max_tries(self) -> int:
"""The number of attempts before giving up when retrying requests.

Returns:
Number of max retries.
"""
return 8
Loading