o
    |j6hÊ/  ã                   @   s¾   d Z ddlZddlZddlZG dd„ deƒZG dd„ deƒ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G dd„ dejƒZG dd„ dejƒZdS )a°  The base interface of RPC Framework.

Implementations of this interface support the conduct of "operations":
exchanges between two distinct ends of an arbitrary number of data payloads
and metadata such as a name for the operation, initial and terminal metadata
in each direction, and flow control. These operations may be used for transfers
of data, remote procedure calls, status indication, or anything else
applications choose.
é    Nc                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚNoSuchMethodErrorau  Indicates that an unrecognized operation has been called.

    Attributes:
      code: A code value to communicate to the other side of the operation
        along with indication of operation termination. May be None.
      details: A details value to communicate to the other side of the
        operation along with indication of operation termination. May be None.
    c                    s   t t| ƒ ¡  || _|| _dS )aZ  Constructor.

        Args:
          code: A code value to communicate to the other side of the operation
            along with indication of operation termination. May be None.
          details: A details value to communicate to the other side of the
            operation along with indication of operation termination. May be None.
        N)Úsuperr   Ú__init__ÚcodeÚdetails)Úselfr   r   ©Ú	__class__© úr/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/grpc/framework/interfaces/base/base.pyr   *   s   	
zNoSuchMethodError.__init__)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__classcell__r
   r
   r   r   r       s    	r   c                   @   ó(   e Zd ZdZejG dd„ dejƒƒZdS )ÚOutcomea@  The outcome of an operation.

    Attributes:
      kind: A Kind value coarsely identifying how the operation terminated.
      code: An application-specific code value or None if no such value was
        provided.
      details: An application-specific details value or None if no such value was
        provided.
    c                   @   s4   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdS )zOutcome.Kindz)Ways in which an operation can terminate.Ú	completedÚ	cancelledÚexpiredzlocal shutdownzremote shutdownzreception failureztransmission failurezlocal failurezremote failureN)r   r   r   r   Ú	COMPLETEDÚ	CANCELLEDÚEXPIREDÚLOCAL_SHUTDOWNÚREMOTE_SHUTDOWNÚRECEPTION_FAILUREÚTRANSMISSION_FAILUREÚLOCAL_FAILUREÚREMOTE_FAILUREr
   r
   r
   r   ÚKindC   s    r   N©r   r   r   r   ÚenumÚuniqueÚEnumr   r
   r
   r
   r   r   8   s    
r   c                   @   s   e Zd ZdZdS )Ú
CompletionzùAn aggregate of the values exchanged upon operation completion.

    Attributes:
      terminal_metadata: A terminal metadata value for the operation.
      code: A code value for the operation.
      message: A message value for the operation.
    N)r   r   r   r   r
   r
   r
   r   r$   R   s    r$   c                   @   sV   e Zd ZdZejdd„ ƒZejdd„ ƒZejdd„ ƒZejdd	„ ƒZ	ejd
d„ ƒZ
dS )ÚOperationContextz2Provides operation-related information and action.c                 C   ó   t ƒ ‚)zÙIndicates the operation's outcome (or that the operation is ongoing).

        Returns:
          None if the operation is still active or the Outcome value for the
            operation if it has terminated.
        ©ÚNotImplementedError©r   r
   r
   r   Úoutcome_   ó   zOperationContext.outcomec                 C   r&   )a  Adds a function to be called upon operation termination.

        Args:
          callback: A callable to be passed an Outcome value on operation
            termination.

        Returns:
          None if the operation has not yet terminated and the passed callback will
            later be called when it does terminate, or if the operation has already
            terminated an Outcome value describing the operation termination and the
            passed callback will not be called as a result of this method call.
        r'   )r   Úcallbackr
   r
   r   Úadd_termination_callbacki   s   z)OperationContext.add_termination_callbackc                 C   r&   )aD  Describes the length of allowed time remaining for the operation.

        Returns:
          A nonnegative float indicating the length of allowed time in seconds
          remaining for the operation to complete before it is considered to have
          timed out. Zero is returned if the operation has terminated.
        r'   r)   r
   r
   r   Útime_remainingy   s   	zOperationContext.time_remainingc                 C   r&   )z>Cancels the operation if the operation has not yet terminated.r'   r)   r
   r
   r   Úcancel„   ó   zOperationContext.cancelc                 C   r&   )z‘Indicates that the operation has failed.

        Args:
          exception: An exception germane to the operation failure. May be None.
        r'   )r   Ú	exceptionr
   r
   r   Úfail‰   ó   zOperationContext.failN)r   r   r   r   ÚabcÚabstractmethodr*   r-   r.   r/   r2   r
   r
   r
   r   r%   \   s    
	



r%   c                   @   s(   e Zd ZdZej				ddd„ƒZdS )ÚOperatorz:An interface through which to participate in an operation.Nc                 C   r&   )aˆ  Progresses the operation.

        Args:
          initial_metadata: An initial metadata value. Only one may ever be
            communicated in each direction for an operation, and they must be
            communicated no later than either the first payload or the completion.
          payload: A payload value.
          completion: A Completion value. May only ever be non-None once in either
            direction, and no payloads may be passed after it has been communicated.
          allowance: A positive integer communicating the number of additional
            payloads allowed to be passed by the remote side of the operation.
        r'   )r   Úinitial_metadataÚpayloadÚ
completionÚ	allowancer
   r
   r   Úadvance–   s   zOperator.advance©NNNN)r   r   r   r   r4   r5   r;   r
   r
   r
   r   r6   “   s    ûr6   c                   @   ó   e Zd ZdZejdd„ ƒZdS )ÚProtocolReceiverz9A means of receiving protocol values during an operation.c                 C   r&   )z™Accepts the protocol context object for the operation.

        Args:
          protocol_context: The protocol context object for the operation.
        r'   )r   Úprotocol_contextr
   r
   r   Úcontext°   r3   zProtocolReceiver.contextN)r   r   r   r   r4   r5   r@   r
   r
   r
   r   r>   ­   ó    r>   c                   @   r   )ÚSubscriptiona½  Describes customer code's interest in values from the other side.

    Attributes:
      kind: A Kind value describing the overall kind of this value.
      termination_callback: A callable to be passed the Outcome associated with
        the operation after it has terminated. Must be non-None if kind is
        Kind.TERMINATION_ONLY. Must be None otherwise.
      allowance: A callable behavior that accepts positive integers representing
        the number of additional payloads allowed to be passed to the other side
        of the operation. Must be None if kind is Kind.FULL. Must not be None
        otherwise.
      operator: An Operator to be passed values from the other side of the
        operation. Must be non-None if kind is Kind.FULL. Must be None otherwise.
      protocol_receiver: A ProtocolReceiver to be passed protocol objects as they
        become available during the operation. Must be non-None if kind is
        Kind.FULL.
    c                   @   s   e Zd ZdZdZdZdS )zSubscription.KindÚnoneztermination onlyÚfullN)r   r   r   ÚNONEÚTERMINATION_ONLYÚFULLr
   r
   r
   r   r   Í   s    r   Nr    r
   r
   r
   r   rB   º   s    rB   c                   @   r=   )ÚServicerz&Interface for service implementations.c                 C   r&   )a  Services an operation.

        Args:
          group: The group identifier of the operation to be serviced.
          method: The method identifier of the operation to be serviced.
          context: An OperationContext object affording contextual information and
            actions.
          output_operator: An Operator that will accept output values of the
            operation.

        Returns:
          A Subscription via which this object may or may not accept more values of
            the operation.

        Raises:
          NoSuchMethodError: If this Servicer does not handle operations with the
            given group and method.
          abandonment.Abandoned: If the operation has been aborted and there no
            longer is any reason to service the operation.
        r'   )r   ÚgroupÚmethodr@   Úoutput_operatorr
   r
   r   Úservice×   ó   zServicer.serviceN)r   r   r   r   r4   r5   rL   r
   r
   r
   r   rH   Ô   rA   rH   c                   @   s`   e Zd ZdZejdd„ ƒZejdd„ ƒZej				ddd„ƒZejd	d
„ ƒZ	ejdd„ ƒZ
dS )ÚEndzBCommon type for entry-point objects on both sides of an operation.c                 C   r&   )z+Starts this object's service of operations.r'   r)   r
   r
   r   Ústartó   r0   z	End.startc                 C   r&   )aÿ  Stops this object's service of operations.

        This object will refuse service of new operations as soon as this method is
        called but operations under way at the time of the call may be given a
        grace period during which they are allowed to finish.

        Args:
          grace: A duration of time in seconds to allow ongoing operations to
            terminate before being forcefully terminated by the stopping of this
            End. May be zero to terminate all ongoing operations and immediately
            stop.

        Returns:
          A threading.Event that will be set to indicate all operations having
            terminated and this End having completely stopped. The returned event
            may not be set until after the full grace period (if some ongoing
            operation continues for the full length of the period) or it may be set
            much sooner (if for example this End had no operations in progress at
            the time its stop method was called).
        r'   )r   Úgracer
   r
   r   Ústopø   rM   zEnd.stopNc	           	      C   r&   )aA  Commences an operation.

        Args:
          group: The group identifier of the invoked operation.
          method: The method identifier of the invoked operation.
          subscription: A Subscription to which the results of the operation will be
            passed.
          timeout: A length of time in seconds to allow for the operation.
          initial_metadata: An initial metadata value to be sent to the other side
            of the operation. May be None if the initial metadata will be later
            passed via the returned operator or if there will be no initial metadata
            passed at all.
          payload: An initial payload for the operation.
          completion: A Completion value indicating the end of transmission to the
            other side of the operation.
          protocol_options: A value specified by the provider of a Base interface
            implementation affording custom state and behavior.

        Returns:
          A pair of objects affording information about the operation and action
            continuing the operation. The first element of the returned pair is an
            OperationContext for the operation and the second element of the
            returned pair is an Operator to which operation values not passed in
            this call should later be passed.
        r'   )	r   rI   rJ   ÚsubscriptionÚtimeoutr7   r8   r9   Úprotocol_optionsr
   r
   r   Úoperate  s   %zEnd.operatec                 C   r&   )zôReports the number of terminated operations broken down by outcome.

        Returns:
          A dictionary from Outcome.Kind value to an integer identifying the number
            of operations that terminated with that outcome kind.
        r'   r)   r
   r
   r   Úoperation_stats7  r+   zEnd.operation_statsc                 C   r&   )z”Adds an action to be called when this End has no ongoing operations.

        Args:
          action: A callable that accepts no arguments.
        r'   )r   Úactionr
   r
   r   Úadd_idle_actionA  r3   zEnd.add_idle_actionr<   )r   r   r   r   r4   r5   rO   rQ   rU   rV   rX   r
   r
   r
   r   rN   ð   s     

÷&
	rN   )r   r4   r!   Ú	threadingÚ	Exceptionr   Úobjectr   ÚABCr$   r%   r6   r>   rB   rH   rN   r
   r
   r
   r   Ú<module>   s   
7