o
    ae4                     @   s   d Z ddlZddlmZmZ ddlZddlmZ ddlm	Z	 ddlm
Z
 ddlmZ dd	lmZ dd
lmZ ddlmZ G dd deeef ejZG dd deeef ejZG dd dejZG dd dejZG dd dejZdS )zDAbstract base classes for Channel objects and Multicallable objects.    N)GenericOptional   )
_base_call)DeserializingFunction)MetadataType)RequestIterableType)RequestType)ResponseType)SerializingFunctionc                   @   l   e Zd ZdZejdddddddedee dee	 dee
j dee d	ee
j d
ejeef fddZdS )UnaryUnaryMultiCallablez4Enables asynchronous invocation of a unary-call RPC.Ntimeoutmetadatacredentialswait_for_readycompressionrequestr   r   r   r   r   returnc                C      dS )ar  Asynchronously invokes the underlying RPC.

        Args:
          request: The request value for the RPC.
          timeout: An optional duration of time in seconds to allow
            for the RPC.
          metadata: Optional :term:`metadata` to be transmitted to the
            service-side of the RPC.
          credentials: An optional CallCredentials for the RPC. Only valid for
            secure Channel.
          wait_for_ready: An optional flag to enable :term:`wait_for_ready` mechanism.
          compression: An element of grpc.compression, e.g.
            grpc.compression.Gzip.

        Returns:
          A UnaryUnaryCall object.

        Raises:
          RpcError: Indicates that the RPC terminated with non-OK status. The
            raised RpcError will also be a Call for the RPC affording the RPC's
            metadata, status code, and details.
        N selfr   r   r   r   r   r   r   r   FD:\Projects\ConvertPro\env\Lib\site-packages\grpc/aio/_base_channel.py__call__!       z UnaryUnaryMultiCallable.__call__)__name__
__module____qualname____doc__abcabstractmethodr	   r   floatr   grpcCallCredentialsboolCompressionr   ZUnaryUnaryCallr
   r   r   r   r   r   r      .    	r   c                   @   r   )UnaryStreamMultiCallablez:Enables asynchronous invocation of a server-streaming RPC.Nr   r   r   r   r   r   r   r   c                C   r   )as  Asynchronously invokes the underlying RPC.

        Args:
          request: The request value for the RPC.
          timeout: An optional duration of time in seconds to allow
            for the RPC.
          metadata: Optional :term:`metadata` to be transmitted to the
            service-side of the RPC.
          credentials: An optional CallCredentials for the RPC. Only valid for
            secure Channel.
          wait_for_ready: An optional flag to enable :term:`wait_for_ready` mechanism.
          compression: An element of grpc.compression, e.g.
            grpc.compression.Gzip.

        Returns:
          A UnaryStreamCall object.

        Raises:
          RpcError: Indicates that the RPC terminated with non-OK status. The
            raised RpcError will also be a Call for the RPC affording the RPC's
            metadata, status code, and details.
        Nr   r   r   r   r   r   G   r   z!UnaryStreamMultiCallable.__call__)r   r   r   r    r!   r"   r	   r   r#   r   r$   r%   r&   r'   r   ZUnaryStreamCallr
   r   r   r   r   r   r)   D   r(   r)   c                   @   h   e Zd ZdZej						ddee dee dee	 dee
j dee dee
j d	ejfd
dZdS )StreamUnaryMultiCallablez:Enables asynchronous invocation of a client-streaming RPC.Nrequest_iteratorr   r   r   r   r   r   c                 C   r   )a  Asynchronously invokes the underlying RPC.

        Args:
          request_iterator: An optional async iterable or iterable of request
            messages for the RPC.
          timeout: An optional duration of time in seconds to allow
            for the RPC.
          metadata: Optional :term:`metadata` to be transmitted to the
            service-side of the RPC.
          credentials: An optional CallCredentials for the RPC. Only valid for
            secure Channel.
          wait_for_ready: An optional flag to enable :term:`wait_for_ready` mechanism.
          compression: An element of grpc.compression, e.g.
            grpc.compression.Gzip.

        Returns:
          A StreamUnaryCall object.

        Raises:
          RpcError: Indicates that the RPC terminated with non-OK status. The
            raised RpcError will also be a Call for the RPC affording the RPC's
            metadata, status code, and details.
        Nr   r   r,   r   r   r   r   r   r   r   r   r   m   r   z!StreamUnaryMultiCallable.__call__NNNNNN)r   r   r   r    r!   r"   r   r   r#   r   r$   r%   r&   r'   r   ZStreamUnaryCallr   r   r   r   r   r+   j   0    r+   c                   @   r*   )StreamStreamMultiCallablezAEnables asynchronous invocation of a bidirectional-streaming RPC.Nr,   r   r   r   r   r   r   c                 C   r   )a  Asynchronously invokes the underlying RPC.

        Args:
          request_iterator: An optional async iterable or iterable of request
            messages for the RPC.
          timeout: An optional duration of time in seconds to allow
            for the RPC.
          metadata: Optional :term:`metadata` to be transmitted to the
            service-side of the RPC.
          credentials: An optional CallCredentials for the RPC. Only valid for
            secure Channel.
          wait_for_ready: An optional flag to enable :term:`wait_for_ready` mechanism.
          compression: An element of grpc.compression, e.g.
            grpc.compression.Gzip.

        Returns:
          A StreamStreamCall object.

        Raises:
          RpcError: Indicates that the RPC terminated with non-OK status. The
            raised RpcError will also be a Call for the RPC affording the RPC's
            metadata, status code, and details.
        Nr   r-   r   r   r   r      r   z"StreamStreamMultiCallable.__call__r.   )r   r   r   r    r!   r"   r   r   r#   r   r$   r%   r&   r'   r   ZStreamStreamCallr   r   r   r   r   r0      r/   r0   c                
   @   sF  e Zd ZdZejdd Zejdd Zejddee	 fdd	Z
ej	
d dedejfddZejdejddfddZejd!ddZej		d"dedee dee defddZej		d"dedee dee defddZej		d"dedee dee defddZej		d"dedee dee defddZdS )#ChannelzEnables asynchronous RPC invocation as a client.

    Channel objects implement the Asynchronous Context Manager (aka. async
    with) type, although they are not supportted to be entered and exited
    multiple times.
    c                       dS )zwStarts an asynchronous context manager.

        Returns:
          Channel the channel that was instantiated.
        Nr   r   r   r   r   
__aenter__       zChannel.__aenter__c                    r2   )zxFinishes the asynchronous context manager by closing the channel.

        Still active RPCs will be cancelled.
        Nr   )r   exc_typeexc_valexc_tbr   r   r   	__aexit__   r5   zChannel.__aexit__Ngracec                    r2   )a   Closes this Channel and releases all resources held by it.

        This method immediately stops the channel from executing new RPCs in
        all cases.

        If a grace period is specified, this method wait until all active
        RPCs are finshed, once the grace period is reached the ones that haven't
        been terminated are cancelled. If a grace period is not specified
        (by passing None for grace), all existing RPCs are cancelled immediately.

        This method is idempotent.
        Nr   )r   r:   r   r   r   close   r5   zChannel.closeFtry_to_connectr   c                 C   r   )a  Checks the connectivity state of a channel.

        This is an EXPERIMENTAL API.

        If the channel reaches a stable connectivity state, it is guaranteed
        that the return value of this function will eventually converge to that
        state.

        Args:
          try_to_connect: a bool indicate whether the Channel should try to
            connect to peer or not.

        Returns: A ChannelConnectivity object.
        Nr   )r   r<   r   r   r   	get_state   r   zChannel.get_statelast_observed_statec                    r2   )a  Waits for a change in connectivity state.

        This is an EXPERIMENTAL API.

        The function blocks until there is a change in the channel connectivity
        state from the "last_observed_state". If the state is already
        different, this function will return immediately.

        There is an inherent race between the invocation of
        "Channel.wait_for_state_change" and "Channel.get_state". The state can
        change arbitrary many times during the race, so there is no way to
        observe every state transition.

        If there is a need to put a timeout for this function, please refer to
        "asyncio.wait_for".

        Args:
          last_observed_state: A grpc.ChannelConnectivity object representing
            the last known state.
        Nr   )r   r>   r   r   r   wait_for_state_change   r5   zChannel.wait_for_state_changec                    r2   )z;Creates a coroutine that blocks until the Channel is READY.Nr   r3   r   r   r   channel_ready	  r5   zChannel.channel_readymethodrequest_serializerresponse_deserializerc                 C   r   )a0  Creates a UnaryUnaryMultiCallable for a unary-unary method.

        Args:
          method: The name of the RPC method.
          request_serializer: Optional :term:`serializer` for serializing the request
            message. Request goes unserialized in case None is passed.
          response_deserializer: Optional :term:`deserializer` for deserializing the
            response message. Response goes undeserialized in case None
            is passed.

        Returns:
          A UnaryUnaryMultiCallable value for the named unary-unary method.
        Nr   r   rA   rB   rC   r   r   r   unary_unary  r   zChannel.unary_unaryc                 C   r   )a4  Creates a UnaryStreamMultiCallable for a unary-stream method.

        Args:
          method: The name of the RPC method.
          request_serializer: Optional :term:`serializer` for serializing the request
            message. Request goes unserialized in case None is passed.
          response_deserializer: Optional :term:`deserializer` for deserializing the
            response message. Response goes undeserialized in case None
            is passed.

        Returns:
          A UnarySteramMultiCallable value for the named unary-stream method.
        Nr   rD   r   r   r   unary_stream"  r   zChannel.unary_streamc                 C   r   )a4  Creates a StreamUnaryMultiCallable for a stream-unary method.

        Args:
          method: The name of the RPC method.
          request_serializer: Optional :term:`serializer` for serializing the request
            message. Request goes unserialized in case None is passed.
          response_deserializer: Optional :term:`deserializer` for deserializing the
            response message. Response goes undeserialized in case None
            is passed.

        Returns:
          A StreamUnaryMultiCallable value for the named stream-unary method.
        Nr   rD   r   r   r   stream_unary7  r   zChannel.stream_unaryc                 C   r   )a8  Creates a StreamStreamMultiCallable for a stream-stream method.

        Args:
          method: The name of the RPC method.
          request_serializer: Optional :term:`serializer` for serializing the request
            message. Request goes unserialized in case None is passed.
          response_deserializer: Optional :term:`deserializer` for deserializing the
            response message. Response goes undeserialized in case None
            is passed.

        Returns:
          A StreamStreamMultiCallable value for the named stream-stream method.
        Nr   rD   r   r   r   stream_streamL  r   zChannel.stream_stream)N)F)r   N)NN)r   r   r   r    r!   r"   r4   r9   r   r#   r;   r&   r$   ZChannelConnectivityr=   r?   r@   strr   r   r   rE   r)   rF   r+   rG   r0   rH   r   r   r   r   r1      s    

r1   )r    r!   typingr   r   r$    r   Z_typingr   r   r   r	   r
   r   ABCr   r)   r+   r0   r1   r   r   r   r   <module>   s    &&&&