kaxil commented on code in PR #26102:
URL: https://github.com/apache/airflow/pull/26102#discussion_r961160649
##########
airflow/providers/google/common/hooks/base_google.py:
##########
@@ -602,3 +603,26 @@ def test_connection(self):
message = str(e)
return status, message
+
+
+class GoogleBaseHookAsync(BaseHook):
+ """GoogleBaseHookAsync inherits from BaseHook class, run on the trigger
worker"""
+
+ sync_hook_class: Any = None
+
+ def __init__(self, **kwargs: Any):
+ self._hook_kwargs = kwargs
+ self._sync_hook = None
+
+ async def get_sync_hook(self) -> Any:
+ """
+ Sync version of the Google Cloud Hooks makes blocking calls in
``__init__`` so we don't inherit
+ from it.
+ """
+ if not self._sync_hook:
+ self._sync_hook = await
sync_to_async(self.sync_hook_class)(**self._hook_kwargs)
+ return self._sync_hook
+
+ async def service_file_as_context(self) -> Any:
+ sync_hook = await self.get_sync_hook()
+ return await
sync_to_async(sync_hook.provide_gcp_credential_file_as_context)()
Review Comment:
Same code as
https://github.com/astronomer/astronomer-providers/blob/main/astronomer/providers/google/common/hooks/base_google.py#L7-L27
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]