o
    KDiu                     @  sP   d dl mZ d dlZd dlmZmZ d dlmZ d dlm	Z	 G dd deZ
dS )    )annotationsN)ABCabstractmethod)
ModuleType)get_package_datac                   @  sh  e Zd ZdZee dZee dZee dZee dZee dZ	ee dZ
dIddZdJddZedKddZedLddZedMd d!ZedMd"d#ZeedNd%d&Ze	'dOdPd+d,ZedQd-d.ZedRd/d0ZedSd3d4ZedTd8d9Ze	'dOdUd:d;Ze	'dOdVd<d=ZedWd?d@ZedXdAdBZedYdDdEZedYdFdGZdHS )ZRedisBridgezresources/redis/lua_scriptsz/moving_window.luaz/acquire_moving_window.luaz/clear_keys.luaz/incr_expire.luaz/sliding_window.luaz/acquire_sliding_window.luauristr
dependencyr   
key_prefixreturnNonec                 C  s\   || _ tj| j | _|| _i | _|| _| jjr| jj| jd< | jj	r,| jj	| jd< d S d S )Nusernamepassword)
r   urllibparseurlparse
parsed_urir
   parsed_authr   r   r   )selfr   r
   r    r   X/var/www/Datamplify/venv/lib/python3.10/site-packages/limits/aio/storage/redis/bridge.py__init__   s   zRedisBridge.__init__keyc                 C  s   | j  d| S )N:)r   r   r   r   r   r   prefixed_key(   s   zRedisBridge.prefixed_keyc                 C     d S Nr   r   r   r   r   register_scripts+      zRedisBridge.register_scriptsservice_name
str | Noneuse_replicasboolsentinel_kwargs$dict[str, str | float | bool] | Noneoptionsstr | float | boolc                 K  r   r   r   )r   r"   r$   r&   r(   r   r   r   use_sentinel.   s   zRedisBridge.use_sentinelc                 K  r   r   r   r   r(   r   r   r   	use_basic7   r!   zRedisBridge.use_basicc                 K  r   r   r   r+   r   r   r   use_cluster:   r!   zRedisBridge.use_cluster-type[Exception] | tuple[type[Exception], ...]c                 C  r   r   r   r   r   r   r   base_exceptions=   s   zRedisBridge.base_exceptions   expiryintamountc                      d S r   r   )r   r   r1   r3   r   r   r   incrC   s   zRedisBridge.incrc                   r4   r   r   r   r   r   r   getK      zRedisBridge.getc                   r4   r   r   r   r   r   r   clearN   r7   zRedisBridge.clearlimittuple[float, int]c                   r4   r   r   )r   r   r9   r1   r   r   r   get_moving_windowQ      zRedisBridge.get_moving_windowprevious_keycurrent_keytuple[int, float, int, float]c                   r4   r   r   )r   r=   r>   r1   r   r   r   get_sliding_windowV   r<   zRedisBridge.get_sliding_windowc                   r4   r   r   )r   r   r9   r1   r3   r   r   r   acquire_entry[   s   zRedisBridge.acquire_entryc                   r4   r   r   )r   r=   r>   r9   r1   r3   r   r   r   acquire_sliding_window_entryd   s   z(RedisBridge.acquire_sliding_window_entryfloatc                   r4   r   r   r   r   r   r   
get_expiryn   r7   zRedisBridge.get_expiryc                   r4   r   r   r   r   r   r   checkq   r7   zRedisBridge.check
int | Nonec                   r4   r   r   r   r   r   r   resett   r7   zRedisBridge.resetc                   r4   r   r   r   r   r   r   	lua_resetw   r7   zRedisBridge.lua_resetN)r   r	   r
   r   r   r	   r   r   )r   r	   r   r	   )r   r   )
r"   r#   r$   r%   r&   r'   r(   r)   r   r   )r(   r)   r   r   )r   r.   )r0   )r   r	   r1   r2   r3   r2   r   r2   )r   r	   r   r2   )r   r	   r   r   )r   r	   r9   r2   r1   r2   r   r:   )r=   r	   r>   r	   r1   r2   r   r?   )
r   r	   r9   r2   r1   r2   r3   r2   r   r%   )r=   r	   r>   r	   r9   r2   r1   r2   r3   r2   r   r%   )r   r	   r   rC   )r   r%   )r   rF   )__name__
__module____qualname__RES_DIRr   SCRIPT_MOVING_WINDOWSCRIPT_ACQUIRE_MOVING_WINDOWSCRIPT_CLEAR_KEYSSCRIPT_INCR_EXPIRESCRIPT_SLIDING_WINDOWSCRIPT_ACQUIRE_SLIDING_WINDOWr   r   r   r    r*   r,   r-   propertyr/   r5   r6   r8   r;   r@   rA   rB   rD   rE   rG   rH   r   r   r   r   r   
   sd    

	r   )
__future__r   r   abcr   r   typesr   limits.utilr   r   r   r   r   r   <module>   s    