a
    v=ic­3  ã                   @   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 G d
d„ dejƒZG dd„ d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)ÚAnyÚOptionalé   )Ú
_base_call)ÚDeserializingFunction)ÚMetadataType)ÚRequestIterableType)ÚSerializingFunctionc                
   @   sX   e Zd ZdZejddddddœeee ee	 ee
j ee ee
j ejdœ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   s   dS )aÀ  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: This is an EXPERIMENTAL argument. An optional
            flag to enable :term:`wait_for_ready` mechanism.
          compression: An element of grpc.compression, e.g.
            grpc.compression.Gzip. This is an EXPERIMENTAL option.

        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   úg/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/grpc/aio/_base_channel.pyÚ__call__   s    z UnaryUnaryMultiCallable.__call__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚabcÚabstractmethodr   r   Úfloatr   ÚgrpcÚCallCredentialsÚboolÚCompressionr   ZUnaryUnaryCallr   r   r   r   r   r
      s    ø÷r
   c                
   @   sX   e Zd ZdZejddddddœeee ee	 ee
j ee ee
j ejdœdd„ƒZdS )ÚUnaryStreamMultiCallablez:Enables asynchronous invocation of a server-streaming RPC.Nr   r   c                C   s   dS )aÁ  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: This is an EXPERIMENTAL argument. An optional
            flag to enable :term:`wait_for_ready` mechanism.
          compression: An element of grpc.compression, e.g.
            grpc.compression.Gzip. This is an EXPERIMENTAL option.

        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   F   s    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$   C   s    ø÷r$   c                
   @   sP   e Zd ZdZejdee ee ee	 ee
j ee ee
j ejdœdd„ƒZdS )ÚStreamUnaryMultiCallablez:Enables asynchronous invocation of a client-streaming RPC.N©Úrequest_iteratorr   r   r   r   r   r   c                 C   s   dS )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: This is an EXPERIMENTAL argument. An optional
            flag to enable :term:`wait_for_ready` mechanism.
          compression: An element of grpc.compression, e.g.
            grpc.compression.Gzip. This is an EXPERIMENTAL option.

        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   s    
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   s"         ùør%   c                
   @   sP   e Zd ZdZejdee ee ee	 ee
j ee ee
j ejdœdd„ƒZdS )ÚStreamStreamMultiCallablezAEnables asynchronous invocation of a bidirectional-streaming RPC.Nr&   c                 C   s   dS )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: This is an EXPERIMENTAL argument. An optional
            flag to enable :term:`wait_for_ready` mechanism.
          compression: An element of grpc.compression, e.g.
            grpc.compression.Gzip. This is an EXPERIMENTAL option.

        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   ”   s    
z"StreamStreamMultiCallable.__call__)NNNNNN)r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r   ZStreamStreamCallr   r   r   r   r   r)   ‘   s"         ùør)   c                   @   s  e Zd ZdZejdd„ ƒZejdd„ ƒZejdee	 dœdd	„ƒZ
ejdeejdœdd„ƒZejejddœdd„ƒZejddœdd„ƒZejdeee ee edœdd„ƒZejd eee ee edœdd„ƒZejd!eee ee edœdd„ƒZejd"eee ee edœdd„ƒZdS )#ÚChannelzßEnables 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                 Ã   s   dS )zwStarts an asynchronous context manager.

        Returns:
          Channel the channel that was instantiated.
        Nr   ©r   r   r   r   Ú
__aenter__À   s    zChannel.__aenter__c                 Ã   s   dS )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__È   s    zChannel.__aexit__N)Úgracec                 Ã   s   dS )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   r1   r   r   r   ÚcloseÏ   s    zChannel.closeF)Útry_to_connectr   c                 C   s   dS )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   r3   r   r   r   Ú	get_stateÞ   s    zChannel.get_state)Úlast_observed_stater   c                 Ã   s   dS )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   r5   r   r   r   Úwait_for_state_changeð   s    zChannel.wait_for_state_change)r   c                 Ã   s   dS )z;Creates a coroutine that blocks until the Channel is READY.Nr   r+   r   r   r   Úchannel_ready
  s    zChannel.channel_ready)ÚmethodÚrequest_serializerÚresponse_deserializerr   c                 C   s   dS )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   r8   r9   r:   r   r   r   Úunary_unary  s    zChannel.unary_unaryc                 C   s   dS )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   r;   r   r   r   Úunary_stream#  s    zChannel.unary_streamc                 C   s   dS )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   r;   r   r   r   Ústream_unary8  s    zChannel.stream_unaryc                 C   s   dS )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   r;   r   r   r   Ústream_streamM  s    zChannel.stream_stream)N)F)NN)NN)NN)NN)r   r   r   r   r   r   r,   r0   r   r   r2   r"   r    ZChannelConnectivityr4   r6   r7   Ústrr	   r   r
   r<   r$   r=   r%   r>   r)   r?   r   r   r   r   r*   ¸   sl   

 ÿÿý  üû  üû  üû  üûr*   )r   r   Útypingr   r   r    Ú r   Z_typingr   r   r   r	   ÚABCr
   r$   r%   r)   r*   r   r   r   r   Ú<module>   s   ''''