1# Copyright 2019 gRPC authors. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15 16cdef class CallbackFailureHandler: 17 cdef str _core_function_name 18 cdef object _error_details 19 cdef object _exception_type 20 21 cdef handle(self, object future) 22 23 24cdef struct CallbackContext: 25 # C struct to store callback context in the form of pointers. 26 # 27 # Attributes: 28 # functor: A grpc_completion_queue_functor represents the 29 # callback function in the only way Core understands. 30 # waiter: An asyncio.Future object that fulfills when the callback is 31 # invoked by Core. 32 # failure_handler: A CallbackFailureHandler object that called when Core 33 # returns 'success == 0' state. 34 # wrapper: A self-reference to the CallbackWrapper to help life cycle 35 # management. 36 grpc_completion_queue_functor functor 37 cpython.PyObject *waiter 38 cpython.PyObject *loop 39 cpython.PyObject *failure_handler 40 cpython.PyObject *callback_wrapper 41 42 43cdef class CallbackWrapper: 44 cdef CallbackContext context 45 cdef object _reference_of_future 46 cdef object _reference_of_failure_handler 47 48 @staticmethod 49 cdef void functor_run( 50 grpc_completion_queue_functor* functor, 51 int succeed) noexcept 52 53 cdef grpc_completion_queue_functor *c_functor(self) 54 55 56cdef class GrpcCallWrapper: 57 cdef grpc_call* call 58