
    i                     (   d dl Z d dlZd dlZd dlZd dlmZmZmZ d dlZ ej                  e
      Z	  G d de j                        Z G d de      Z G d dej                  ej                   ej"                  ej$                        Z G d	 d
e      Zy)    N)OptionalTuple
NamedTuplec                   6    e Zd Zej                  defd       Zy)SleepPolicytry_ic                     |dk\  sJ y)zs
        How long to sleep in milliseconds.
        :param try_i: the number of retry (starting from zero)
        r   N )selfr   s     e/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/pinecone/grpc/retry.pysleepzSleepPolicy.sleep   s     zz    N)__name__
__module____qualname__abcabstractmethodintr   r
   r   r   r   r      s!    3  r   r   c                   ,    e Zd ZdededefdZdefdZy)ExponentialBackoffinit_backoff_msmax_backoff_ms
multiplierc                V    t        j                  d|      | _        || _        || _        y )Nr   )randomrandintinit_backoffmax_backoffr   )r   r   r   r   s       r   __init__zExponentialBackoff.__init__   s$    "NN1o>)$r   r   c                     t        | j                  | j                  |z  z  | j                        }t	        j
                  d|      }t        j                  d| d       t        j                  |dz         y )Nr   zgRPC retry. Sleeping for msi  )
minr   r   r   r   r   _loggerdebugtimer   )r   r   sleep_rangesleep_mss       r   r   zExponentialBackoff.sleep   s^    $++doou.DDdFVFVW>>![11(2>?

8d?#r   N)r   r   r   r   r   r   r
   r   r   r   r      s)    %3 % %QT %
$3 $r   r   c                   <    e Zd ZdZd
dZd Zd Zd Zd Zd Z	d Z
y	) RetryOnRpcErrorClientInterceptorz`gRPC retry.

    Referece: https://github.com/grpc/grpc/issues/19514#issuecomment-531700657
    c                 j    |j                   | _         |j                  | _        |j                  | _        y N)max_attemptssleep_policyretryable_status)r   retry_configs     r   r   z)RetryOnRpcErrorClientInterceptor.__init__0   s,    (55(55 , = =r   c                     t        |t        j                        xr6 d|j                  j                  vxr |j                         | j                  v S )z-Determine if a response is a retryable error._MultiThreadedRendezvous)
isinstancegrpcRpcError	__class__r   coder.   )r   response_or_errors     r   _is_retryable_errorz4RetryOnRpcErrorClientInterceptor._is_retryable_error5   sP     ($--8 B*2C2M2M2V2VVB!&&(D,A,AA	
r   c                     d }t        | j                        D ]:  } |||      }| j                  |      s |S | j                  j	                  |       < |S r+   )ranger,   r8   r-   r   )r   continuationclient_call_detailsrequest_or_iteratorresponser   s         r   _intercept_callz0RetryOnRpcErrorClientInterceptor._intercept_call=   sb    4,,- 	+E#$79LMH++H5 ##E*		+
 r   c                 (    | j                  |||      S r+   r?   r   r;   r<   requests       r   intercept_unary_unaryz6RetryOnRpcErrorClientInterceptor.intercept_unary_unaryF       ##L2EwOOr   c                 (    | j                  |||      S r+   rA   rB   s       r   intercept_unary_streamz7RetryOnRpcErrorClientInterceptor.intercept_unary_streamI   rE   r   c                 (    | j                  |||      S r+   rA   r   r;   r<   request_iterators       r   intercept_stream_unaryz7RetryOnRpcErrorClientInterceptor.intercept_stream_unaryL       ##L2EGWXXr   c                 (    | j                  |||      S r+   rA   rI   s       r   intercept_stream_streamz8RetryOnRpcErrorClientInterceptor.intercept_stream_streamO   rL   r   N)r/   RetryConfig)r   r   r   __doc__r   r8   r?   rD   rG   rK   rN   r
   r   r   r)   r)   %   s.    
>

PPYYr   r)   c                       e Zd ZU dZdZeed<    eddd      Ze	ed<   e
j                  j                  fZeee
j                  d	f      ed
<   y)rO   z Config settings related to retry   r,   d   i@     )r   r   r   r-   .r.   N)r   r   r   rP   r,   r   __annotations__r   r-   r   r3   
StatusCodeUNAVAILABLEr.   r   r   r
   r   r   rO   rO   S   sV    *L# 2DQ!L+  @D?Z?Z>\huT__c%9:;\r   rO   )r   loggingr   r%   typingr   r   r   r3   	getLoggerr   r#   ABCr   r   UnaryUnaryClientInterceptorUnaryStreamClientInterceptorStreamUnaryClientInterceptorStreamStreamClientInterceptorr)   rO   r
   r   r   <module>r`      s    
    . .  '

H
% #'' 
$ 
$+Y$$%%%%&&	+Y\]* ]r   