Skip to content

Commit

Permalink
Adds the request timeout configuration (#275)
Browse files Browse the repository at this point in the history
* Adds the request timeout configuration

* Bumps the version to take advantage of request timeout
  • Loading branch information
verdan authored and feng-tao committed Aug 26, 2019
1 parent 641c168 commit bdc7344
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
9 changes: 5 additions & 4 deletions frontend/amundsen_application/api/utils/request_utils.py
Expand Up @@ -3,8 +3,6 @@
import requests
from flask import current_app as app

REQUEST_SESSION_TIMEOUT_SEC = 3


def get_query_param(args: Dict, param: str, error_msg: str = None) -> str:
value = args.get(param)
Expand All @@ -17,7 +15,7 @@ def get_query_param(args: Dict, param: str, error_msg: str = None) -> str:
def request_metadata(*, # type: ignore
url: str,
method: str = 'GET',
timeout_sec: int = REQUEST_SESSION_TIMEOUT_SEC):
timeout_sec: int = 0):
"""
Helper function to make a request to metadata service.
Sets the client and header information based on the configuration
Expand All @@ -40,7 +38,7 @@ def request_metadata(*, # type: ignore
def request_search(*, # type: ignore
url: str,
method: str = 'GET',
timeout_sec: int = REQUEST_SESSION_TIMEOUT_SEC):
timeout_sec: int = 0):
"""
Helper function to make a request to search service.
Sets the client and header information based on the configuration
Expand Down Expand Up @@ -71,6 +69,9 @@ def request_wrapper(method: str, url: str, client, headers, timeout_sec: int):
:param timeout_sec: Number of seconds before timeout is triggered. Not used with Envoy
:return:
"""
# If no timeout specified, use the one from the configurations.
timeout_sec = timeout_sec or app.config['REQUEST_SESSION_TIMEOUT_SEC']

if client is not None:
if method == 'DELETE':
return client.delete(url, headers=headers, raw_response=True)
Expand Down
3 changes: 3 additions & 0 deletions frontend/amundsen_application/config.py
Expand Up @@ -15,6 +15,9 @@ class Config:
# Number of popular tables to be displayed on the index/search page
POPULAR_TABLE_COUNT = 4 # type: int

# Request Timeout Configurations in Seconds
REQUEST_SESSION_TIMEOUT_SEC = 3


class LocalConfig(Config):
DEBUG = False
Expand Down
2 changes: 1 addition & 1 deletion frontend/setup.py
Expand Up @@ -34,7 +34,7 @@ def build_js() -> None:
with open(requirements_path) as requirements_file:
requirements = requirements_file.readlines()

__version__ = '1.0.6'
__version__ = '1.0.7'


setup(
Expand Down

0 comments on commit bdc7344

Please sign in to comment.