
    ,i                         d dl mZmZ d dlmZmZ d dlZd dlmZ d dlm	Z	 d dl
mZ d dlmZ  G d d	e      Z G d
 de      Z G d de      Ze	eeef      Z G d dee      Zy)    )ABCabstractmethod)OptionalUnionN)RedisCluster)WeightedList)CircuitBreaker)Numberc                       e Zd Zeedefd              Zej                  edefd              Zeedee	   fd              Z
e
j                  edee	   fd              Z
y)	AbstractDatabasereturnc                      y)z]The weight of this database in compare to others. Used to determine the database failover to.N selfs    [/var/www/html/langgraph-service/venv/lib/python3.12/site-packages/redis/multidb/database.pyweightzAbstractDatabase.weight        	    r   c                      y)z5Set the weight of this database in compare to others.Nr   r   r   s     r   r   zAbstractDatabase.weight   r   r   c                      y)z6Health check URL associated with the current database.Nr   r   s    r   health_check_urlz!AbstractDatabase.health_check_url   r   r   r   c                      y)z>Set the health check URL associated with the current database.Nr   r   r   s     r   r   z!AbstractDatabase.health_check_url   r   r   N)__name__
__module____qualname__propertyr   floatr   setterr   strr   r   r   r   r   r      s        ]]U    (3-    #   r   r   c                       e Zd Z	 d
dedee   fdZedefd       Zej                  defd       Zedee   fd       Z
e
j                  dee   fd	       Z
y)BaseDatabaseNr   r   c                      || _         || _        y N)_weight_health_check_url)r   r   r   s      r   __init__zBaseDatabase.__init__&   s    
 !1r   r   c                     | j                   S r&   r'   r   s    r   r   zBaseDatabase.weight.       ||r   c                     || _         y r&   r+   r   s     r   r   zBaseDatabase.weight2   	    r   c                     | j                   S r&   r(   r   s    r   r   zBaseDatabase.health_check_url6   s    %%%r   c                     || _         y r&   r0   r   s     r   r   zBaseDatabase.health_check_url:   s
    !1r   r&   )r   r   r   r    r   r"   r)   r   r   r!   r   r   r   r   r$   r$   %   s     +/22 #3-2    ]]U   &(3- & & 2# 2 2r   r$   c                       e Zd ZdZeedeej                  e	f   fd              Z
e
j                  edeej                  e	f   fd              Z
eedefd              Zej                  edefd              Zy	)
SyncDatabasez5Database with an underlying synchronous redis client.r   c                      y)zThe underlying redis client.Nr   r   s    r   clientzSyncDatabase.clientB   r   r   r5   c                      y)z Set the underlying redis client.Nr   r   r5   s     r   r5   zSyncDatabase.clientH   r   r   c                      y)z)Circuit breaker for the current database.Nr   r   s    r   circuitzSyncDatabase.circuitN   r   r   r9   c                      y)z1Set the circuit breaker for the current database.Nr   r   r9   s     r   r9   zSyncDatabase.circuitT   r   r   N)r   r   r   __doc__r   r   r   redisRedisr   r5   r!   r	   r9   r   r   r   r3   r3   ?   s    ?ekk<78    ]]U5;;#<=        ^^~   r   r3   c            
           e Zd Z	 ddeej
                  ef   dedede	e
   f fdZedeej
                  ef   fd       Zej                  deej
                  ef   fd       Zedefd	       Zej                  defd
       Z xZS )Databaser5   r9   r   r   c                 d    || _         || _        | | j                  _        t        |   ||       y)at  
        Initialize a new Database instance.

        Args:
            client: Underlying Redis client instance for database operations
            circuit: Circuit breaker for handling database failures
            weight: Weight value used for database failover prioritization
            health_check_url: Health check URL associated with the current database
        N)_client_cbdatabasesuperr)   )r   r5   r9   r   r   	__class__s        r   r)   zDatabase.__init___   s/       !12r   r   c                     | j                   S r&   rB   r   s    r   r5   zDatabase.clientt   r,   r   c                     || _         y r&   rH   r7   s     r   r5   zDatabase.clientx   r.   r   c                     | j                   S r&   rC   r   s    r   r9   zDatabase.circuit|   s    xxr   c                     || _         y r&   rK   r;   s     r   r9   zDatabase.circuit   s	    r   r&   )r   r   r   r   r=   r>   r   r	   r    r   r"   r)   r   r5   r!   r9   __classcell__)rF   s   @r   r@   r@   ^   s     +/3ekk</03  3 	3
 #3-3* ekk<78   ]]U5;;#<=      ^^~  r   r@   )abcr   r   typingr   r   r=   r   redis.data_structurer   redis.multidb.circuitr	   redis.typingr
   r   r$   r3   tuple	Databasesr@   r   r   r   <module>rU      sd    # "   - 0 s 42# 24# 8 |V345	$|\ $r   