o
    |j6hE6                     @   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   e/var/www/html/chefvision.cloud.itp360.com/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      .    	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   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   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__r0   )r   r   r   r    r!   r"   r   r   r#   r   r$   r%   r&   r'   r   StreamStreamCallr   r   r   r   r   r3      r2   r3   c                   @   sn  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e def
ddZej			
d#dede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e def
ddZej			
d#dede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 supported 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                    r6   )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__   r9   zChannel.__aexit__Ngracec                    r6   )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 waits until all active
        RPCs are finished or until the grace period is reached. RPCs that haven't
        been terminated within the grace period are aborted.
        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   r9   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                    r6   )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   rB   r   r   r   wait_for_state_change   r9   zChannel.wait_for_state_changec                    r6   )z;Creates a coroutine that blocks until the Channel is READY.Nr   r7   r   r   r   channel_ready
  r9   zChannel.channel_readymethodrequest_serializerresponse_deserializer_registered_methodc                 C   r   )a  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.
          _registered_method: Implementation Private. Optional: A bool representing
            whether the method is registered.

        Returns:
          A UnaryUnaryMultiCallable value for the named unary-unary method.
        Nr   r   rE   rF   rG   rH   r   r   r   unary_unary  r   zChannel.unary_unaryc                 C   r   )a  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.
          _registered_method: Implementation Private. Optional: A bool representing
            whether the method is registered.

        Returns:
          A UnaryStreamMultiCallable value for the named unary-stream method.
        Nr   rI   r   r   r   unary_stream&  r   zChannel.unary_streamc                 C   r   )a  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.
          _registered_method: Implementation Private. Optional: A bool representing
            whether the method is registered.

        Returns:
          A StreamUnaryMultiCallable value for the named stream-unary method.
        Nr   rI   r   r   r   stream_unary>  r   zChannel.stream_unaryc                 C   r   )a  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.
          _registered_method: Implementation Private. Optional: A bool representing
            whether the method is registered.

        Returns:
          A StreamStreamMultiCallable value for the named stream-stream method.
        Nr   rI   r   r   r   stream_streamV  r   zChannel.stream_stream)N)F)r   N)NNF)r   r   r   r    r!   r"   r8   r=   r   r#   r?   r&   r$   ChannelConnectivityrA   rC   rD   strr   r   r   rJ   r*   rK   r-   rL   r3   rM   r   r   r   r   r5      s    

r5   )r    r!   typingr   r   r$    r   _typingr   r   r   r	   r
   r   ABCr   r*   r-   r3   r5   r   r   r   r   <module>   s    &&&&