
    5j                        S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr  \(       a   \" S	S
S9 " S S\5      5       rg)    )annotations)TYPE_CHECKING)versionchanged)Version)parse_storage_uri)ConfigurationError)RedisStorage)RedisClientz4.3zuAdded support for using the redis client from :pypi:`valkey` if :paramref:`uri` has the ``valkey+sentinel://`` schema)versionreasonc                     ^  \ rS rSrSrSS/r \" S5      \" S5      \" S5      \" S5      S.rSS	S\R                  S
4               SU 4S jjjr
\  SS j5       rSSS jjrSrU =r$ )RedisSentinelStorage   z
Rate limit storage with redis sentinel as backend

Depends on :pypi:`redis` package (or :pypi:`valkey` if :paramref:`uri` starts with
``valkey+sentinel://``)
zredis+sentinelzvalkey+sentinelz3.0z6.0)rediszredis.sentinelvalkeyzvalkey.sentinelNTFc                  > [         [        U ]
  " U4SU0UD6  [        U5      n/ n	U(       a  UR	                  5       O0 n
0 nUR                  SUR                  5      =n(       a  XS'   UR                  SUR                  5      =n(       a  XS'   U	R                  UR                  5        XPl
        UR                  (       a  UR                  R                  SS5      OUU l        U R                  c  [        S5      eUR                  S5      (       a  SOS	U l        U R"                  U R                    S
3   R$                  nUR&                  " U	4S0 UEU
E00 UEUED6U l        U R(                  R+                  U R                  5      U l        U R(                  R/                  U R                  5      U l        X0l        U R5                  U5        g)aM  
:param uri: url of the form
 ``redis+sentinel://host:port,host:port/service_name``

 If the uri scheme is ``valkey+sentinel`` the implementation used will be from
 :pypi:`valkey`.
:param service_name: sentinel service name
 (if not provided in :attr:`uri`)
:param use_replicas: Whether to use replicas for read only operations
:param sentinel_kwargs: kwargs to pass as
 :attr:`sentinel_kwargs` to :class:`redis.sentinel.Sentinel`
:param key_prefix: the prefix for each key created in redis
:param wrap_exceptions: Whether to wrap storage exceptions in
 :exc:`limits.errors.StorageError` before raising it.
:param options: all remaining keyword arguments are passed
 directly to the constructor of :class:`redis.sentinel.Sentinel`
:raise ConfigurationError: when the redis library is not available
 or if the redis master host cannot be pinged.
wrap_exceptionsusernamepassword/ Nz'service_name' not providedr   r   z	.sentinelsentinel_kwargs)superr	   __init__r   copygetr   r   extend	locations
key_prefixpathreplaceservice_namer   
startswithtarget_serverdependenciesmoduleSentinelsentinel
master_forstorage	slave_forstorage_slaveuse_replicasinitialize_storage)selfurir"   r-   r   r   r   optionsstorage_uri_optionssentinel_configurationsentinel_optionsparsed_authr   r   sentinel_dep	__class__s                  \/root/lseg-credit/backend/venv/lib/python3.13/site-packages/limits/storage/redis_sentinel.pyr   RedisSentinelStorage.__init__*   s   < 	lD*	
!0	
4;	
 04!#5D?//1"57{{:/B/K/KLL8L&.
#{{:/B/K/KLL8L&.
#%%&9&C&CD$ #''  $$,,S"5 	 $$%BCC),)A)AXw((D,>,>+?y)IJQQ$--"
?{?.>?
 )((

 %)MM$<$<T=N=N$O*.--*A*A$BSBS*T($    c                    U R                   S:X  a#  U R                  S   R                  R                  $ U R                  S   R                  R                  $ )Nr   r   )r$   r%   r&   
RedisErrorValkeyError)r/   s    r8   base_exceptions$RedisSentinelStorage.base_exceptionsn   sT     !!W, g&--88	
 ""8,33??	
r:   c                b    U(       a  U R                   (       a  U R                  $ U R                  $ )N)r-   r,   r*   )r/   readonlys     r8   get_connection#RedisSentinelStorage.get_connectionx   s!    &.43D3Dt!!W4<<Wr:   )r   r(   r"   r*   r,   r$   r-   )r0   strr"   z
str | Noner-   boolr   z$dict[str, float | str | bool] | Noner   rD   r   rE   r1   zfloat | str | boolreturnNone)rF   z-type[Exception] | tuple[type[Exception], ...])F)rA   rE   rF   r
   )__name__
__module____qualname____firstlineno____doc__STORAGE_SCHEMEr   DEPENDENCIESr	   PREFIXr   propertyr>   rB   __static_attributes____classcell__)r7   s   @r8   r   r      s     '(9:NQ !%.%."5>	L $(!@D&-- %B%B% !B% 	B%
 >B% B% B% &B% 
B% B%H 
	6
 
X Xr:   r   N)
__future__r   typingr   deprecated.sphinxr   packaging.versionr   limits._storage_schemer   limits.errorsr   limits.storage.redisr	   limits.typingr
   r    r:   r8   <module>r\      sR    "   , % 4 , - % 	DaX< aXaXr:   