U
    N8c                     @   s.   d dl mZ eddddgZG dd dZdS )	    )
namedtupleCubicParamsw_maxk	last_failc                   @   sB   e Zd ZdZdZeefddZdd Zdd Zd	d
 Zdd Z	dS )CubicCalculatorg?gffffff?c                 C   s&   || _ || _|| _|  | _|| _d S N)_w_max_scale_constant_beta_calculate_zero_point_k
_last_fail)selfZstarting_max_rate
start_timeZscale_constantbeta r   ?/tmp/pip-unpacked-wheel-ozje0y8b/botocore/retries/throttling.py__init__
   s
    
zCubicCalculator.__init__c                 C   s"   | j d| j  | j }|d }|S )N   gUUUUUU?)r	   r   r
   )r   Zscaled_valuer   r   r   r   r      s    z%CubicCalculator._calculate_zero_pointc                 C   s(   || j  }| j|| j d  | j }|S )N   )r   r
   r   r	   )r   	timestampdtZnew_rater   r   r   success_received   s    
z CubicCalculator.success_receivedc                 C   s    || _ |  | _|| _|| j S r   )r	   r   r   r   r   )r   Zcurrent_rater   r   r   r   error_received!   s    
zCubicCalculator.error_receivedc                 C   s   t | j| j| jdS )aX  Return a read-only object of the current cubic parameters.

        These parameters are intended to be used for debug/troubleshooting
        purposes.  These object is a read-only snapshot and cannot be used
        to modify the behavior of the CUBIC calculations.

        New parameters may be added to this object in the future.

        )r   r   r   )r   r	   r   r   )r   r   r   r   get_params_snapshot+   s
    
  z#CubicCalculator.get_params_snapshotN)
__name__
__module____qualname__Z_SCALE_CONSTANTZ_BETAr   r   r   r   r   r   r   r   r   r      s   

r   N)collectionsr   r   r   r   r   r   r   <module>   s   