jgao54 commented on a change in pull request #4101: add base grpc hook
URL: https://github.com/apache/incubator-airflow/pull/4101#discussion_r228641432
 
 

 ##########
 File path: airflow/contrib/hooks/grpc_hook.py
 ##########
 @@ -0,0 +1,102 @@
+# -*- coding: utf-8 -*-
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from airflow.hooks.base_hook import BaseHook
+from airflow.exceptions import AirflowException
+import grpc
+from google import auth as google_auth
+from google.auth import jwt as google_auth_jwt
+from google.auth.transport import grpc as google_auth_transport_grpc
+
+class GrpcHook(BaseHook):
+       """
+       General interaction with GRPC servers.
+       """
+
+       def __init__(self, grpc_conn_id, interceptors=[], 
custom_connection_func=None):
+               self.grpc_conn_id = grpc_conn_id
+               self.conn = self.get_connection(self.grpc_conn_id)
+               self.extras = conn.extra_dejson
+               self.interceptors = interceptors
+               self.custom_connection_func = custom_connection_func
+
+       def get_conn(self):
+               if "://" in self.conn.host:
+            base_url = self.conn.host
+        else:
+            # schema defaults to HTTP
+            schema = self.conn.schema if self.conn.schema else "http"
+            base_url = schema + "://" + self.conn.host
+
+               if self.conn.port:
+            base_url = base_url + ":" + str(self.conn.port) + "/"
+
+        auth_type = self._get_field("auth_type")
 
 Review comment:
   nit: indentation is off here

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to