You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/04/14 21:02:25 UTC

[GitHub] [airflow] feluelle commented on a change in pull request #4923: [AIRFLOW-4092] Add gRPCOperator, unit test and added to auto doc

feluelle commented on a change in pull request #4923: [AIRFLOW-4092] Add gRPCOperator, unit test and added to auto doc
URL: https://github.com/apache/airflow/pull/4923#discussion_r275174106
 
 

 ##########
 File path: airflow/contrib/operators/grpc_operator.py
 ##########
 @@ -0,0 +1,98 @@
+# -*- coding: utf-8 -*-
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.contrib.hooks.grpc_hook import GrpcHook
+from airflow.models import BaseOperator
+from airflow.utils.decorators import apply_defaults
+
+
+class GrpcOperator(BaseOperator):
+    """
+    Calls a gRPC endpoint to execute an action
+
+    :param stub_class: The stub client to use for this gRPC call
+    :type stub_class: gRPC stub class generated from proto file
+    :param call_func: The client function name to call the gRPC endpoint
+    :type call_func: gRPC client function name for the endpoint generated from proto file, str
+    :param grpc_conn_id: The connection to run the operator against
+    :type grpc_conn_id: str
+    :param data: The data to pass to the rpc call
+    :type data: A dict with key value pairs as kwargs of the call_func
+    :param interceptors: A list of gRPC interceptor objects to be used on the channel
+    :type interceptors: A list of gRPC interceptor objects, has to be initialized
+    :param custom_connection_func: The customized connection function to return channel object
+    :type custom_connection_func: A python function that returns channel object, take in
+        a connection object, can be a partial function
+    :param response_callback: The callback function to process the response from gRPC call
 
 Review comment:
   Please change the order of the docstring params to be the same as they appear in the `__init__`. See `response_callback` and `streaming`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services