o
    û/‚i§  ã                   @   s   d Z G dd„ dƒZdS )z4Base class for bi-directional streaming RPC helpers.c                   @   sJ   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zedd„ ƒZ	edd„ ƒZ
dS )ÚBidiRpcBasea¤  A base class for consuming a bi-directional streaming RPC.

    This maps gRPC's built-in interface which uses a request iterator and a
    response iterator into a socket-like :func:`send` and :func:`recv`. This
    is a more useful pattern for long-running or asymmetric streams (streams
    where there is not a direct correlation between the requests and
    responses).

    This does *not* retry the stream on errors.

    Args:
        start_rpc (Union[grpc.StreamStreamMultiCallable,
                    grpc.aio.StreamStreamMultiCallable]): The gRPC method used
                    to start the RPC.
        initial_request (Union[protobuf.Message,
                Callable[[], protobuf.Message]]): The initial request to
            yield. This is useful if an initial request is needed to start the
            stream.
        metadata (Sequence[Tuple(str, str)]): RPC metadata to include in
            the request.
    Nc                 C   s2   || _ || _|| _|  ¡ | _d | _g | _d | _d S ©N)Ú
_start_rpcÚ_initial_requestÚ_rpc_metadataÚ_create_queueÚ_request_queueÚ_request_generatorÚ
_callbacksÚcall)ÚselfÚ	start_rpcÚinitial_requestÚmetadata© r   úM/var/www/passon-env/lib/python3.10/site-packages/google/api_core/bidi_base.pyÚ__init__'   s   

zBidiRpcBase.__init__c                 C   ó   t dƒ‚)zCreate a queue for requests.z#`_create_queue` is not implemented.©ÚNotImplementedError©r   r   r   r   r   0   s   zBidiRpcBase._create_queuec                 C   s   | j  |¡ dS )aá  Adds a callback that will be called when the RPC terminates.

        This occurs when the RPC errors or is successfully terminated.

        Args:
            callback (Union[Callable[[grpc.Future], None], Callable[[Any], None]]):
                The callback to execute after gRPC call completed (success or
                failure).

                For sync streaming gRPC: Callable[[grpc.Future], None]

                For async streaming gRPC: Callable[[Any], None]
        N)r	   Úappend)r   Úcallbackr   r   r   Úadd_done_callback4   s   zBidiRpcBase.add_done_callbackc                 C   s   | j D ]}||ƒ qd S r   )r	   )r   Úfuturer   r   r   r   Ú_on_call_doneD   s   
	
ÿzBidiRpcBase._on_call_donec                 C   r   )z&True if the gRPC call is not done yet.z`is_active` is not implemented.r   r   r   r   r   Ú	is_activeP   s   zBidiRpcBase.is_activec                 C   s
   | j  ¡ S )z*Estimate of the number of queued requests.)r   Úqsizer   r   r   r   Úpending_requestsU   s   
zBidiRpcBase.pending_requests)NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Úpropertyr   r   r   r   r   r   r      s    
	
r   N)r!   r   r   r   r   r   Ú<module>   s   