
    0WRiF                     \    d dl mZmZmZmZ d dlmZ d dlmZ d dl	m
Z
 d Z G d de
      Zy)	    )parse_qs	urlencodeurlparse
urlunparse)ImproperlyConfigured)SentinelConnectionPool)DefaultClientc                 H    t        g | d d t        |d      | d         S )N   T)doseq   )r   r   )urlquerys     z/var/www/html/navyabakers_fullstack/navyabakers_prod/venv_new/lib/python3.12/site-packages/django_redis/client/sentinel.pyreplace_queryr   	   s.    FBQF5!=Fs1vFGG    c                   ,     e Zd ZdZ fdZ fdZ xZS )SentinelClienta3  
    Sentinel client which uses the single redis URL specified by the CACHE's
    LOCATION to create a LOCATION configuration for two connection pools; One
    pool for the primaries and another pool for the replicas, and upon
    connecting ensures the connection pool factory is configured correctly.
    c                     t        |t              rTt        |      }t        |j                  d      }t        |      }dg|d<   dg|d<   ||fD cg c]  }t        ||       }}t        | !  |||       y c c}w )NT)keep_blank_values   	is_masterr   )	
isinstancestrr   r   r   dictr   super__init__)	selfserverparamsbackendr   primary_queryreplica_queryi	__class__s	           r   r   zSentinelClient.__init__   s    fc"6"C$SYY$GM /M*+M+&*+M+&6C]5STmC+TFT1 Us   A8c                 t    t        |   |i |}t        |j                  t              sd}t        |      |S )NznSettings DJANGO_REDIS_CONNECTION_FACTORY or CACHE[].OPTIONS.CONNECTION_POOL_CLASS is not configured correctly.)r   connectr   connection_poolr   r   )r   argskwargs
connectionerror_messager%   s        r   r'   zSentinelClient.connect!   sE    W_d5f5
*446LMU  '}55r   )__name__
__module____qualname____doc__r   r'   __classcell__)r%   s   @r   r   r      s    
2	 	r   r   N)urllib.parser   r   r   r   django.core.exceptionsr   redis.sentinelr   django_redis.client.defaultr	   r   r    r   r   <module>r7      s&    B B 7 1 5H] r   