Skip to content

Commit

Permalink
Merge pull request #4 from dominodatalab/ddl-giuliocapolino.DOM-33794…
Browse files Browse the repository at this point in the history
….avoid-timeout-if-pod-dies

datasourceSDK: avoid timeouts when ds proxy dies
  • Loading branch information
ddl-giuliocapolino authored Nov 2, 2021
2 parents f4b1952 + 8ad3ae8 commit 8c8d5a3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Temporary Items
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
.idea/

# Gradle
.idea/**/gradle.xml
Expand Down
23 changes: 14 additions & 9 deletions domino_data/data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,7 @@ def __attrs_post_init__(self):
proxy_host=proxy_host,
)

self.proxy = flight.FlightClient(
flight_host,
middleware=[
AuthMiddlewareFactory(
self.api_key,
self.token_file,
)
],
)
self._set_proxy()
self.proxy_http = AuthenticatedClient(
base_url=proxy_host,
api_key=self.api_key,
Expand All @@ -511,6 +503,18 @@ def __attrs_post_init__(self):
headers=ACCEPT_HEADERS,
)

def _set_proxy(self):
flight_host = os.getenv("DOMINO_DATASOURCE_PROXY_FLIGHT_HOST")
self.proxy = flight.FlightClient(
flight_host,
middleware=[
AuthMiddlewareFactory(
self.api_key,
self.token_file,
)
],
)

def get_datasource(self, name: str) -> Datasource:
"""Fetch a datasource by name.
Expand Down Expand Up @@ -647,6 +651,7 @@ def execute(
logger.info("execute", datasource_id=datasource_id, query=query)

try:
self._set_proxy()
reader = self._do_get(
BoardingPass(
datasource_id=datasource_id,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "dominodatalab-data"
version = "0.1.2"
version = "0.1.3"
description = "Domino Data SDK for interacting with Access Data features"
readme = "README.md"
authors = [
Expand Down

0 comments on commit 8c8d5a3

Please sign in to comment.