-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22091d5
commit 4037d55
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
metadata-ingestion/src/datahub/ingestion/run/connection.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import logging | ||
|
||
from datahub.ingestion.api.source import TestConnectionReport | ||
from datahub.ingestion.source.source_registry import source_registry | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class ConnectionManager: | ||
"""A class that helps build / manage / triage connections""" | ||
|
||
def test_source_connection(self, recipe_config_dict: dict) -> TestConnectionReport: | ||
# pulls out the source component of the dictionary | ||
# walks the type registry to find the source class | ||
# calls specific class.test_connection | ||
try: | ||
source_type = recipe_config_dict.get("source", {}).get("type") | ||
source_class = source_registry.get(source_type) | ||
return source_class.test_connection( | ||
recipe_config_dict.get("source", {}).get("config", {}) | ||
) | ||
except Exception as e: | ||
logger.error(e) | ||
raise e |