Ë
    ±Œj½  ã                  ó¤   — d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	  edd¬«       ed	d
¬«       edd¬«       G d„ de	«      «       «       «       Z
y)é    )Úannotations)Úversionchanged)ÚVersion)Úparse_storage_uri)ÚRedisStoragez3.14.0z_
Dropped support for the :pypi:`redis-py-cluster` library
which has been abandoned/deprecated.
)ÚversionÚreasonz2.5.0aa  
Cluster support was provided by the :pypi:`redis-py-cluster` library
which has been absorbed into the official :pypi:`redis` client. By
default the :class:`redis.cluster.RedisCluster` client will be used
however if the version of the package is lower than ``4.2.0`` the implementation
will fallback to trying to use :class:`rediscluster.RedisCluster`.
z4.3ztAdded support for using the redis client from :pypi:`valkey` if :paramref:`uri` has the ``valkey+cluster://`` schemac                  óš   ‡ — e Zd ZU dZddgZ	 ddiZded<   	  ed«       ed	«      d
œZe	j                  df	 	 	 	 	 	 	 	 	 dˆ fd„Zdd„Zˆ xZS )ÚRedisClusterStoragez¦
    Rate limit storage with redis cluster as backend

    Depends on :pypi:`redis` (or :pypi:`valkey` if :paramref:`uri`
    starts with ``valkey+cluster://``).
    zredis+clusterzvalkey+clusterÚmax_connectionsiè  zdict[str, float | str | bool]ÚDEFAULT_OPTIONSz4.2.0z6.0)ÚredisÚvalkeyFc                ó.  •— t        |«      }i }|j                  d|j                  «      x}r||d<   |j                  d|j                  «      x}r||d<   |j                  }	|| _        d| _        |j                  d«      rdnd| _        | j                  | j                     j                  | _        |	D �
cg c]%  }
 | j                  j                  j                  |
Ž ‘Œ' }}
i | j                  ¥d|i¥|¥|¥}| j                  dk(  r, | j                  j                  j                  di |¤Ž| _        n+ | j                  j                  j                   di |¤Ž| _        | j                  sJ ‚| j#                  |«       t%        t&        | �R  ||fi |¤Ž yc c}
w )a¸  
        :param uri: url of the form
         ``redis+cluster://[:password]@host:port,host:port``

         If the uri scheme is ``valkey+cluster`` the implementation used will be from
         :pypi:`valkey`.
        :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.cluster.RedisCluster`
        :raise ConfigurationError: when the :pypi:`redis` library is not
         available or if the redis cluster cannot be reached.
        ÚusernameÚpasswordNr   r   Ústartup_nodes© )r   Úgetr   r   Ú	locationsÚ
key_prefixÚstorageÚ
startswithÚtarget_serverÚdependenciesÚmoduleÚ
dependencyÚclusterÚClusterNoder   ÚRedisClusterÚValkeyClusterÚinitialize_storageÚsuperr   Ú__init__)ÚselfÚurir   Úwrap_exceptionsÚoptionsÚstorage_uri_optionsÚparsed_authr   r   Úcluster_hostsÚcr   Úmerged_optionsÚ	__class__s                €úf/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/limits/storage/redis_cluster.pyr$   zRedisClusterStorage.__init__7   s™  ø€ ô* 0°Ó4ÐØˆØ—{‘{ :Ð/B×/KÑ/KÓLÐLˆ8ÐLØ&.ˆK˜
Ñ#Ø—{‘{ :Ð/B×/KÑ/KÓLÐLˆ8ÐLØ&.ˆK˜
Ñ#à+×5Ñ5ˆà$ˆŒØˆŒØ),¯©¸Ô)A™XÀwˆÔØ×+Ñ+¨D×,>Ñ,>Ñ?×FÑFˆŒÙJWÓXÉ-ÀQÐ<˜Ÿ™×0Ñ0×<Ñ<¸aÒ@È-ˆÐXð
Ø×"Ñ"ð
à Ð.ð
ð ð
ð ð	
ˆð ×Ñ Ò(Ø?˜4Ÿ?™?×2Ñ2×?Ñ?ÑQÀ.ÑQˆD�Là@˜4Ÿ?™?×2Ñ2×@Ñ@ÑRÀ>ÑRˆDŒLà�|Š|Ðˆ|Ø×Ñ Ô$ÜŒl˜DÑ*¨3°ÑKÀ7ÓKùò Ys   Â5*Fc                ó@  — | j                  d«      }d}| j                  j                  «       D ]h  }| j                  j                  |«      }|j	                  |«      }|t        |D �cg c]"  }|j                  |j                  d«      «      ‘Œ$ c}«      z  }Œj |S c c}w )aé  
        Redis Clusters are sharded and deleting across shards
        can't be done atomically. Because of this, this reset loops over all
        keys that are prefixed with :paramref:`RedisClusterStorage.prefix` and
        calls delete on them one at a time.

        .. warning::
         This operation was not tested with extremely large data sets.
         On a large production based system, care should be taken with its
         usage as it could be slow on very large data setsÚ*r   zutf-8)Úprefixed_keyr   Úget_primariesÚget_redis_connectionÚkeysÚsumÚdeleteÚdecode)r%   ÚprefixÚcountÚprimaryÚnoder5   Úks          r/   ÚresetzRedisClusterStorage.reseti   s�   € ð ×"Ñ" 3Ó'ˆØˆØ—|‘|×1Ñ1Ö3ˆGØ—<‘<×4Ñ4°WÓ=ˆDØ—9‘9˜VÓ$ˆDØ”SÁ$ÓGÁ$¸Q˜$Ÿ+™+ a§h¡h¨wÓ&7Õ8À$ÑGÓHÑH‰Eð 4ð ˆùò Hs   Á''B)
r&   Ústrr   r?   r'   Úboolr(   zfloat | str | boolÚreturnÚNone)rA   z
int | None)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚSTORAGE_SCHEMEr   Ú__annotations__r   ÚDEPENDENCIESr   ÚPREFIXr$   r>   Ú__classcell__)r.   s   @r/   r   r   
   s›   ø… ñ2ð &Ð'7Ð8€NØ.ð 	˜4ð6€OÐ2ó ð Iñ ˜Ó!Ù˜%“.ñ€Lð '×-Ñ-Ø %ð	0Làð0Lð ð0Lð ð	0Lð
 &ð0Lð 
õ0L÷dó    r   N)Ú
__future__r   Údeprecated.sphinxr   Úpackaging.versionr   Úlimits._storage_schemer   Úlimits.storage.redisr   r   r   rL   r/   Ú<module>rR      sn   ðÝ "å ,Ý %å 4Ý -ñ Øðôñ Øðô	ñ Øð	CôôY˜,ó Yóó	óñ0YrL   