o
    ˷e3                     @   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                   @   d   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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 )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   M/var/www/ideatree/venv/lib/python3.10/site-packages/grpc/aio/_base_channel.py__call__       z UnaryUnaryMultiCallable.__call__)__name__
__module____qualname____doc__abcabstractmethodr   r   floatr   grpcCallCredentialsboolCompressionr   UnaryUnaryCallr   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   )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   r   z!UnaryStreamMultiCallable.__call__)r   r   r   r   r   r    r   r   r!   r   r"   r#   r$   r%   r   UnaryStreamCallr   r   r   r   r   r(   C   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: 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   r   z!StreamUnaryMultiCallable.__call__NNNNNN)r   r   r   r   r   r    r   r   r!   r   r"   r#   r$   r%   r   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: 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      r   z"StreamStreamMultiCallable.__call__r.   )r   r   r   r   r   r    r   r   r!   r   r"   r#   r$   r%   r   StreamStreamCallr   r   r   r   r   r1      r0   r1   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                    r4   )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__   r7   zChannel.__aexit__Ngracec                    r4   )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   r7   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                    r4   )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   r7   zChannel.wait_for_state_changec                    r4   )z;Creates a coroutine that blocks until the Channel is READY.Nr   r5   r   r   r   channel_ready
  r7   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   rC   rD   rE   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   rF   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   rF   r   r   r   stream_unary8  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   rF   r   r   r   stream_streamM  r   zChannel.stream_stream)N)F)r   N)NN)r   r   r   r   r   r    r6   r;   r   r!   r=   r$   r"   ChannelConnectivityr?   rA   rB   strr	   r   r   rG   r(   rH   r+   rI   r1   rJ   r   r   r   r   r3      s    

r3   )r   r   typingr   r   r"    r   _typingr   r   r   r	   ABCr   r(   r+   r1   r3   r   r   r   r   <module>   s   ''''