Ë
    3ýjlb  ã                   óº  — d dl Z d dlZd dlZd dlmZmZmZmZmZ d dl	m
Z
mZ d dlmZ d dlmZ d dlmZ d dlmZmZ 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 d dlm Z m!Z!m"Z"m#Z# d dl$m%Z%m&Z&m'Z' d dl(m)Z)m*Z*m+Z+ d dl,m-Z- d dl.m/Z/ d dl0m1Z1 d dl2m3Z3m4Z4m5Z5 d dl6m7Z7  ejp                  e9«      Z:e7 G d„ dee«      «       Z;defd„Z< G d„ dee«      Z= G d„ d«      Z>y)é    N)ÚAnyÚCallableÚListÚLiteralÚOptional)ÚHealthCheckÚHealthCheckPolicy)ÚBackgroundScheduler)Ú	NoBackoff)ÚPubSubWorkerThread)ÚCoreCommandsÚRedisModuleCommands)Ú	DataError)ÚMaintNotificationsConfig)ÚCircuitBreaker)ÚState)ÚDefaultCommandExecutor)ÚDEFAULT_GRACE_PERIODÚDatabaseConfigÚInitialHealthCheckÚMultiDbConfig)ÚDatabaseÚ	DatabasesÚSyncDatabase)ÚInitialHealthCheckFailedErrorÚNoValidDatabaseExceptionÚUnhealthyDatabaseException)ÚFailureDetector)ÚGeoFailoverReason)ÚRetry)ÚChannelTÚPubSubHandlerÚSubscription)Úexperimentalc                   ó`  — e Zd ZdZdefd„Zd„ Zd„ Zdefd„Z	de
dd	fd
„Z	 d,dedefd„Zde
de
fd„Zdefd„Zde
defd„Zdefd„Zdefd„Zd„ ZdZdededefd„Zdededefd„Zdededefd„Zdededefd„Zd„ Zd e d!gd	f   fd"„Z!d#„ Z"de
defd$„Z#de$eef   fd%„Z%d&„ Z&d'e'd(e(d)e(fd*„Z)d+„ Z*y	)-ÚMultiDBClientzŠ
    Client that operates on multiple logical Redis databases.
    Should be used in Client-side geographic failover database setups.
    Úconfigc           
      óÈ  — |j                  «       | _        |j                  s|j                  «       n|j                  | _        |j
                  | _        |j                  j                  «       | _	        |j                  s|j                  «       n|j                  | _        |j                  €|j                  «       n|j                  | _        | j                  j!                  | j                  «       |j"                  | _        |j&                  | _        |j*                  | _        | j,                  j/                  t0        f«       t3        | j                  | j                  | j,                  | j                  |j4                  |j6                  | j(                  | j$                  ¬«      | _        d| _        t=        «       | _        tA        jB                  «       | _"        || _#        y )N)Úfailure_detectorsÚ	databasesÚcommand_retryÚfailover_strategyÚfailover_attemptsÚfailover_delayÚevent_dispatcherÚauto_fallback_intervalF)$r*   Ú
_databasesÚhealth_checksÚdefault_health_checksÚ_health_checksÚhealth_check_intervalÚ_health_check_intervalÚhealth_check_policyÚvalueÚ_health_check_policyr)   Údefault_failure_detectorsÚ_failure_detectorsr,   Údefault_failover_strategyÚ_failover_strategyÚset_databasesr0   Ú_auto_fallback_intervalr/   Ú_event_dispatcherr+   Ú_command_retryÚupdate_supported_errorsÚConnectionRefusedErrorr   r-   r.   Úcommand_executorÚinitializedr
   Ú_bg_schedulerÚ	threadingÚLockÚ_hc_lockÚ_config)Úselfr'   s     úN/root/telegram-saas/.venv/lib/python3.12/site-packages/redis/multidb/client.pyÚ__init__zMultiDBClient.__init__,   s–  € Ø ×*Ñ*Ó,ˆŒð ×'Ò'ð ×(Ñ(Ô*à×%Ñ%ð 	Ôð
 '-×&BÑ&BˆÔ#à×&Ñ&×,Ñ,Ó.ð 	Ô!ð
 ×+Ò+ð ×,Ñ,Ô.à×)Ñ)ð 	Ôð ×'Ñ'Ð/ð ×,Ñ,Ô.à×)Ñ)ð 	Ôð
 	×Ñ×-Ñ-¨d¯o©oÔ>Ø'-×'DÑ'DˆÔ$Ø!'×!8Ñ!8ˆÔØ$×2Ñ2ˆÔØ×Ñ×3Ñ3Ô5KÐ4MÔNÜ 6Ø"×5Ñ5Ø—o‘oØ×-Ñ-Ø"×5Ñ5Ø$×6Ñ6Ø!×0Ñ0Ø!×3Ñ3Ø#'×#?Ñ#?ô	!
ˆÔð !ˆÔÜ0Ó2ˆÔÜ!Ÿ™Ó(ˆŒØˆ�ó    c                 óD   — 	 | j                  «        y # t        $ r Y y w xY w©N)ÚcloseÚ	Exception©rK   s    rL   Ú__del__zMultiDBClient.__del__V   s$   € ð	Ø�J‰J�LøÜò 	ñ ð		úó   ‚ “	žc                 óÈ  — | j                   j                  | j                  «       | j                   j                  | j                  | j
                  «       d}| j                  D ]h  \  }}|j                  j                  | j                  «       |j                  j                  t        j                  k(  sŒS|rŒV|| j                  _        d}Œj |st        d«      ‚d| _        y)zT
        Perform initialization of databases to define their initial state.
        FTz4Initial connection failed - no active database foundN)rF   Úrun_coro_syncÚ_perform_initial_health_checkÚrun_recurring_coror6   Ú_check_databases_healthr1   ÚcircuitÚon_state_changedÚ!_on_circuit_state_change_callbackÚstateÚCBStateÚCLOSEDrD   Ú_active_databaser   rE   )rK   Úis_active_db_foundÚdatabaseÚweights       rL   Ú
initializezMultiDBClient.initialize_   sÓ   € ð 	×Ñ×(Ñ(¨×)KÑ)KÔLð 	×Ñ×-Ñ-Ø×'Ñ'Ø×(Ñ(ô	
ð
 #Ðà $§¡ò 		*ÑˆH�fà×Ñ×-Ñ-¨d×.TÑ.TÔUð ×Ñ×%Ñ%¬¯©Ó7Ò@Rð :B�×%Ñ%Ô6Ø%)Ñ"ð		*ñ "Ü*ØFóð ð  ˆÕrN   Úreturnc                 ó   — | j                   S )zE
        Returns a sorted (by weight) list of all databases.
        )r1   rS   s    rL   Úget_databaseszMultiDBClient.get_databases…   s   € ð �‰ÐrN   rc   Nc                 ó�  — d}| j                   D ]  \  }}||k(  sŒd} n |st        d«      ‚| j                  j                  | j                  |«       |j
                  j                  t        j                  k(  rC| j                   j                  d«      d   \  }}|t        j                  f| j                  _        yt        d«      ‚)zL
        Promote one of the existing databases to become an active.
        NTú/Given database is not a member of database listé   r   z1Cannot set active database, database is unhealthy)r1   Ú
ValueErrorrF   rW   Ú_check_db_healthr[   r^   r_   r`   Ú	get_top_nr   ÚMANUALrD   Úactive_databaser   )rK   rc   ÚexistsÚexisting_dbÚ_Úhighest_weighted_dbs         rL   Úset_active_databasez!MultiDBClient.set_active_database‹   sÅ   € ð ˆà"Ÿo™oò 	‰NˆK˜Ø˜hÓ&Ø�Ùð	ñ
 ÜÐNÓOÐOà×Ñ×(Ñ(¨×)>Ñ)>ÀÔIà×Ñ×!Ñ!¤W§^¡^Ò3Ø%)§_¡_×%>Ñ%>¸qÓ%AÀ!Ñ%DÑ"Ð àÜ!×(Ñ(ð5ˆD×!Ñ!Ô1ð ä&Ø?ó
ð 	
rN   Úskip_initial_health_checkc                 ó  — t        dt        «       ¬«      |j                  d<   d|j                  vrt        d¬«      |j                  d<   |j                  r< | j
                  j                  j                  |j                  fi |j                  ¤Ž}n‘|j                  r_|j                  j                  t        dt        «       ¬«      «       | j
                  j                  j                  |j                  ¬«      }n& | j
                  j                  di |j                  ¤Ž}|j                  €|j                  «       n|j                  }t        |||j                  |j                  ¬	«      }	 | j                  j                  | j                   |«       | j$                  j'                  d
«      d   \  }}| j$                  j)                  ||j                  «       | j+                  ||«       y# t"        $ r |s‚ Y Œhw xY w)zù
        Adds a new database to the database list.

        Args:
            config: DatabaseConfig object that contains the database configuration.
            skip_initial_health_check: If True, adds the database even if it is unhealthy.
        r   )ÚretriesÚbackoffÚretryÚmaint_notifications_configF)Úenabled)Úconnection_poolN)Úclientr[   rd   Úhealth_check_urlrk   © )r    r   Úclient_kwargsr   Úfrom_urlrJ   Úclient_classÚ	from_poolÚ	set_retryr[   Údefault_circuit_breakerr   rd   r   rF   rW   rm   r   r1   rn   ÚaddÚ_change_active_database)rK   r'   rv   r~   r[   rc   rt   Úhighest_weights           rL   Úadd_databasezMultiDBClient.add_database§   sÀ  € ô ).°aÄÃÔ(Mˆ×Ñ˜WÑ%ð (¨v×/CÑ/CÑCä(°Ô7ð × Ñ Ð!=Ñ>ð �?Š?Ø7�T—\‘\×.Ñ.×7Ñ7Ø—‘ñØ#)×#7Ñ#7ñ‰Fð ×ÒØ×Ñ×&Ñ&¤u°QÄ	ÃÔ'LÔMØ—\‘\×.Ñ.×8Ñ8Ø &× 0Ñ 0ð 9ó ‰Fð /�T—\‘\×.Ñ.ÑF°×1EÑ1EÑFˆFð �~‰~Ð%ð ×*Ñ*Ô,à—‘ð 	ô ØØØ—=‘=Ø#×4Ñ4ô	
ˆð	Ø×Ñ×,Ñ,¨T×-BÑ-BÀHÔMð
 /3¯o©o×.GÑ.GÈÓ.JÈ1Ñ.MÑ+Ð˜^Ø�‰×Ñ˜H h§o¡oÔ6Ø×$Ñ$ XÐ/BÕCøô *ò 	Ù,Øñ -ð	ús   Å/&G/ Ç/G>Ç=G>Únew_databaseÚhighest_weight_databasec                 óÊ   — |j                   |j                   kD  rJ|j                  j                  t        j                  k(  r"|t
        j                  f| j                  _        y y y rP   )	rd   r[   r^   r_   r`   r   Ú	AUTOMATICrD   rp   )rK   r‹   rŒ   s      rL   rˆ   z%MultiDBClient._change_active_databaseß   sZ   € ð ×ÑÐ"9×"@Ñ"@Ò@Ø×$Ñ$×*Ñ*¬g¯n©nÒ<ð Ü!×+Ñ+ð5ˆD×!Ñ!Õ1ð =ð ArN   c                 ó  — | j                   j                  |«      }| j                   j                  d«      d   \  }}||k  rJ|j                  j                  t
        j                  k(  r"|t        j                  f| j                  _
        yyy)z<
        Removes a database from the database list.
        rk   r   N)r1   Úremovern   r[   r^   r_   r`   r   ro   rD   rp   )rK   rc   rd   rt   r‰   s        rL   Úremove_databasezMultiDBClient.remove_databaseë   s‚   € ð —‘×'Ñ'¨Ó1ˆØ.2¯o©o×.GÑ.GÈÓ.JÈ1Ñ.MÑ+Ð˜^ð ˜fÒ$Ø#×+Ñ+×1Ñ1´W·^±^ÒCð $Ü!×(Ñ(ð5ˆD×!Ñ!Õ1ð Dð %rN   rd   c                 ó  — d}| j                   D ]  \  }}||k(  sŒd} n |st        d«      ‚| j                   j                  d«      d   \  }}| j                   j                  ||«       ||_        | j                  ||«       y)z<
        Updates a database from the database list.
        NTrj   rk   r   )r1   rl   rn   Úupdate_weightrd   rˆ   )rK   rc   rd   rq   rr   rs   rt   r‰   s           rL   Úupdate_database_weightz$MultiDBClient.update_database_weightû   sŒ   € ð ˆà"Ÿo™oò 	‰NˆK˜Ø˜hÓ&Ø�Ùð	ñ
 ÜÐNÓOÐOà.2¯o©o×.GÑ.GÈÓ.JÈ1Ñ.MÑ+Ð˜^Ø�‰×%Ñ% h°Ô7Ø ˆŒØ×$Ñ$ XÐ/BÕCrN   Úfailure_detectorc                 ó:   — | j                   j                  |«       y)z>
        Adds a new failure detector to the database.
        N)r;   Úappend)rK   r•   s     rL   Úadd_failure_detectorz"MultiDBClient.add_failure_detector  s   € ð 	×Ñ×&Ñ&Ð'7Õ8rN   Úhealthcheckc                 ó|   — | j                   5  | j                  j                  |«       ddd«       y# 1 sw Y   yxY w)z:
        Adds a new health check to the database.
        N)rI   r4   r—   )rK   r™   s     rL   Úadd_health_checkzMultiDBClient.add_health_check  s4   € ð �]‰]ñ 	4Ø×Ñ×&Ñ& {Ô3÷	4÷ 	4ñ 	4ús   �2²;c                 ór   — | j                   s| j                  «         | j                  j                  |i |¤ŽS )zB
        Executes a single command and return its result.
        )rE   re   rD   Úexecute_command©rK   ÚargsÚoptionss      rL   r�   zMultiDBClient.execute_command  s5   € ð ×ÒØ�O‰OÔà4ˆt×$Ñ$×4Ñ4°dÐF¸gÑFÐFrN   zEHIMPORT is not supported on the multi-database (Active-Active) clientrŸ   Úkwargsc                 ó,   — t        | j                  «      ‚rP   ©r   Ú_HIMPORT_UNSUPPORTED©rK   rŸ   r¡   s      rL   Úhimport_preparezMultiDBClient.himport_prepare/  ó   € Ü˜×1Ñ1Ó2Ð2rN   c                 ó,   — t        | j                  «      ‚rP   r£   r¥   s      rL   Úhimport_setzMultiDBClient.himport_set2  r§   rN   c                 ó,   — t        | j                  «      ‚rP   r£   r¥   s      rL   Úhimport_discardzMultiDBClient.himport_discard5  r§   rN   c                 ó,   — t        | j                  «      ‚rP   r£   r¥   s      rL   Úhimport_discard_allz!MultiDBClient.himport_discard_all8  r§   rN   c                 ó   — t        | «      S )z:
        Enters into pipeline mode of the client.
        )ÚPipelinerS   s    rL   ÚpipelinezMultiDBClient.pipeline;  s   € ô ˜‹~ÐrN   Úfuncr¯   c                 óx   — | j                   s| j                  «         | j                  j                  |g|¢|¢­Ž S )z3
        Executes callable as transaction.
        )rE   re   rD   Úexecute_transaction)rK   r±   Úwatchesr    s       rL   ÚtransactionzMultiDBClient.transactionA  s:   € ð ×ÒØ�O‰OÔà8ˆt×$Ñ$×8Ñ8¸ÐRÀÐRÈ'ÒRÐRrN   c                 óR   — | j                   s| j                  «        t        | fi |¤ŽS )z¨
        Return a Publish/Subscribe object. With this object, you can
        subscribe to channels and listen for messages that get published to
        them.
        )rE   re   ÚPubSub)rK   r¡   s     rL   ÚpubsubzMultiDBClient.pubsubJ  s'   € ð ×ÒØ�O‰OÔä�dÑ%˜fÑ%Ð%rN   c              ƒ   óê  K  — | j                   5  t        | j                  «      }ddd«       | j                  j	                  |«      ƒ d{  –—† }|sH|j
                  j                  t        j                  k7  rt        j                  |j
                  _        |S |rF|j
                  j                  t        j                  k7  rt        j                  |j
                  _        |S # 1 sw Y   ŒÁxY w7 Œ¤­w)zO
        Runs health checks on the given database until first failure.
        N)
rI   Úlistr4   r9   Úexecuter[   r^   r_   ÚOPENr`   )rK   rc   r2   Ú
is_healthys       rL   rm   zMultiDBClient._check_db_healthU  s¼   è ø€ ð �]‰]ñ 	6Ü  ×!4Ñ!4Ó5ˆM÷	6ð  ×4Ñ4×<Ñ<¸]ÈHÓU×Uˆ
áØ×Ñ×%Ñ%¬¯©Ò5Ü)0¯©�× Ñ Ô&ØÐÙ˜H×,Ñ,×2Ñ2´g·n±nÒDÜ%,§^¡^ˆH×ÑÔ"àÐ÷	6ð 	6úð Vús(   ‚C3�C%¥'C3ÁC1ÁBC3Ã%C.Ã*C3c              ƒ   óz  K  — i }g | _         | j                  D ]I  \  }}t        j                  | j	                  |«      «      }|||<   | j                   j                  |«       ŒK t        j                  | j                   ddiŽƒ d{  –—† }t        | j                   |«      D ��ci c]  \  }}||   |“Œ }}}|j                  «       D ]g  \  }}t        |t        «      sŒ|j                  }t        j                  |j                  _        t         j#                  d|j$                  ¬«       d||<   Œi |S 7 Œ¬c c}}w ­w)zk
        Runs health checks as a recurring task.
        Runs health checks against all databases.
        Úreturn_exceptionsTNz%Health check failed, due to exception)Úexc_infoF)Ú	_hc_tasksr1   ÚasyncioÚcreate_taskrm   r—   ÚgatherÚzipÚitemsÚ
isinstancer   rc   r_   r¼   r[   r^   ÚloggerÚdebugÚoriginal_exception)	rK   Ú
task_to_dbrc   rs   ÚtaskÚresultsÚresultÚ
db_resultsÚunhealthy_dbs	            rL   rZ   z%MultiDBClient._check_databases_healthh  s4  è ø€ ð
 46ˆ
àˆŒØŸ?™?ò 	(‰KˆH�aÜ×&Ñ& t×'<Ñ'<¸XÓ'FÓGˆDØ'ˆJ�tÑØ�N‰N×!Ñ! $Õ'ð	(ô
  Ÿ™¨¯©ÐOÈ$ÑO×Oˆô :=¸T¿^¹^ÈWÓ9U÷
Ù)5¨¨vˆJ�tÑ˜fÑ$ð
ˆ
ñ 
ð !+× 0Ñ 0Ó 2ò 
	1ÑˆH�fÜ˜&Ô"<Õ=Ø%Ÿ™�Ü-4¯\©\�×$Ñ$Ô*ä—‘Ø;Ø#×6Ñ6ð ô ð
 ,1�
˜<Ò(ð
	1ð Ðð' Púó
ùs+   ‚BD;ÂD3ÂD;Â$D5Â4)D;ÃAD;Ä5D;c              ƒ   ó  K  — | j                  «       ƒ d{  –—† }d}| j                  j                  t        j                  k(  rd|j                  «       v}n‰| j                  j                  t        j                  k(  r)t        |j                  «       «      t        |«      dz  kD  }n9| j                  j                  t        j                  k(  rd|j                  «       v }|s"t        d| j                  j                  › �«      ‚y7 Œî­w)zj
        Runs initial health check and evaluate healthiness based on initial_health_check_policy.
        NTFé   z:Initial health check failed. Initial health check policy: )rZ   rJ   Úinitial_health_check_policyr   ÚALL_AVAILABLEÚvaluesÚMAJORITY_AVAILABLEÚsumÚlenÚONE_AVAILABLEr   )rK   rÍ   r½   s      rL   rX   z+MultiDBClient._perform_initial_health_checkŠ  sÝ   è ø€ ð ×4Ñ4Ó6×6ˆØˆ
à�<‰<×3Ñ3Ô7I×7WÑ7WÒWØ g§n¡nÓ&6Ð6‰Jà�L‰L×4Ñ4Ü!×4Ñ4ò5ô ˜WŸ^™^Ó-Ó.´°W³ÀÑ1AÑA‰Jà�L‰L×4Ñ4Ô8J×8XÑ8XÒXà §¡Ó!1Ð1ˆJáÜ/ØLÈTÏ\É\×MuÑMuÐLvÐwóð ð ð 7ús   ‚D–D—C/Dr[   Ú	old_stateÚ	new_statec                 óþ  — |t         j                  k(  r1| j                  j                  | j                  |j
                  «       y |t         j                  k(  r[|t         j                  k(  rHt        j                  d|j
                  › d�«       | j                  j                  t        t        |«       |t         j                  k7  r8|t         j                  k(  r$t        j                  d|j
                  › d�«       y y y )Nz	Database z- is unreachable. Failover has been initiated.z is reachable again.)r_   Ú	HALF_OPENrF   Úrun_coro_fire_and_forgetrm   rc   r`   r¼   rÈ   ÚwarningÚrun_oncer   Ú_half_open_circuitÚinfo)rK   r[   rÚ   rÛ   s       rL   r]   z/MultiDBClient._on_circuit_state_change_callback¢  sÐ   € ð œ×)Ñ)Ò)Ø×Ñ×7Ñ7Ø×%Ñ% w×'7Ñ'7ôð àœŸ™Ò&¨9¼¿¹Ò+DÜ�N‰NØ˜G×,Ñ,Ð-Ð-ZÐ[ôð ×Ñ×'Ñ'Ü$Ô&8¸'ôð œŸ™Ò&¨9¼¿¹Ò+FÜ�K‰K˜) G×$4Ñ$4Ð#5Ð5IÐJÕKð ,GÐ&rN   c                 óX  — | j                   rJ	 | j                   j                  | j                  j                  «       | j                   j                  «        | j                  j                  r/| j                  j                  j                  j                  «        yy# t        $ r Y Œkw xY w)z:
        Closes the client and all its resources.
        N)	rF   rW   r9   rQ   rR   ÚstoprD   rp   r~   rS   s    rL   rQ   zMultiDBClient.close·  sŒ   € ð ×ÒðØ×"Ñ"×0Ñ0°×1JÑ1J×1PÑ1PÔQð ×Ñ×#Ñ#Ô%à× Ñ ×0Ò0Ø×!Ñ!×1Ñ1×8Ñ8×>Ñ>Õ@ð 1øô	 ò Ùðús   Ž/B Â	B)Â(B))T)+Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   rM   rT   re   r   rh   r   ru   r   ÚboolrŠ   rˆ   r   r‘   Úfloatr”   r   r˜   r   r›   r�   r¤   r   r¦   r©   r«   r­   r°   r   rµ   r¸   rm   ÚdictrZ   rX   r   r_   r]   rQ   r€   rN   rL   r&   r&   %   sŸ  „ ñð
(˜}ó (òTò$ ðL˜yó ð
¨Lð 
¸Tó 
ð: IMñ6DØ$ð6DØAEó6Dðp
Ø(ð
ØCOó
ð¨ó ð D¨|ð DÀUó Dð&9°_ó 9ð4¨Kó 4òGð" 	Pð ð3 Sð 3°Cð 3¸Có 3ð3 ð 3°ð 3¸ó 3ð3 Sð 3°Cð 3¸Có 3ð3¨ð 3¸ð 3Àó 3òðS ¨*¨°tÐ);Ñ <ó Sò	&ð¨|ð Àó ð& ¨t°H¸d°NÑ/Có  òDð0LØ%ðLØ29ðLØFMóLó*ArN   r&   r[   c                 ó.   — t         j                  | _        y rP   )r_   rÝ   r^   )r[   s    rL   rá   rá   Ê  s   € Ü×%Ñ%€G…MrN   c                   óÞ   — e Zd ZU dZdZed   ed<   defd„Zdd„Z	d„ Z
d	„ Zdefd
„Zdefd„Zdd„Zdd„Zdd„Zd„ Zdededefd„Zdededefd„Zdededefd„Zdededefd„Zdee   fd„Zy)r¯   zG
    Pipeline implementation for multiple logical Redis databases.
    FÚ_is_async_clientr~   c                 ó    — g | _         || _        y rP   )Ú_command_stackÚ_client)rK   r~   s     rL   rM   zPipeline.__init__Õ  s   € Ø ˆÔØˆ�rN   rf   c                 ó   — | S rP   r€   rS   s    rL   Ú	__enter__zPipeline.__enter__Ù  ó   € ØˆrN   c                 ó$   — | j                  «        y rP   ©Úreset)rK   Úexc_typeÚ	exc_valueÚ	tracebacks       rL   Ú__exit__zPipeline.__exit__Ü  ó   € Ø�
‰
�rN   c                 óD   — 	 | j                  «        y # t        $ r Y y w xY wrP   ©r÷   rR   rS   s    rL   rT   zPipeline.__del__ß  s"   € ð	Ø�J‰J�LøÜò 	Ùð	úrU   c                 ó,   — t        | j                  «      S rP   )rØ   rð   rS   s    rL   Ú__len__zPipeline.__len__å  s   € Ü�4×&Ñ&Ó'Ð'rN   c                  ó   — y)z1Pipeline instances should always evaluate to TrueTr€   rS   s    rL   Ú__bool__zPipeline.__bool__è  s   € àrN   Nc                 ó   — g | _         y rP   )rð   rS   s    rL   r÷   zPipeline.resetì  s
   € Ø ˆÕrN   c                 ó$   — | j                  «        y)zClose the pipelineNrö   rS   s    rL   rQ   zPipeline.closeï  s   € à�
‰
�rN   c                 ó@   — | j                   j                  ||f«       | S )ar  
        Stage a command to be executed when execute() is next called

        Returns the current Pipeline object back so commands can be
        chained together, such as:

        pipe = pipe.set('foo', 'bar').incr('baz').decr('bang')

        At some other point, you can then run: pipe.execute(),
        which will execute all commands queued in the pipe.
        )rð   r—   rž   s      rL   Úpipeline_execute_commandz!Pipeline.pipeline_execute_commandó  s!   € ð 	×Ñ×"Ñ" D¨' ?Ô3ØˆrN   c                 ó&   —  | j                   |i |¤ŽS )zAdds a command to the stack)r  r¥   s      rL   r�   zPipeline.execute_command  s   € à,ˆt×,Ñ,¨dÐ=°fÑ=Ð=rN   rŸ   r¡   c                 ó4   — t        t        j                  «      ‚rP   ©r   r&   r¤   r¥   s      rL   r¦   zPipeline.himport_prepare
  ó   € Üœ×:Ñ:Ó;Ð;rN   c                 ó4   — t        t        j                  «      ‚rP   r	  r¥   s      rL   r©   zPipeline.himport_set  r
  rN   c                 ó4   — t        t        j                  «      ‚rP   r	  r¥   s      rL   r«   zPipeline.himport_discard  r
  rN   c                 ó4   — t        t        j                  «      ‚rP   r	  r¥   s      rL   r­   zPipeline.himport_discard_all  r
  rN   c                 ó  — | j                   j                  s| j                   j                  «        	 | j                   j                  j	                  t        | j                  «      «      | j                  «        S # | j                  «        w xY w)z0Execute all the commands in the current pipeline)rñ   rE   re   rD   Úexecute_pipelineÚtuplerð   r÷   rS   s    rL   r»   zPipeline.execute  s_   € à�|‰|×'Ò'Ø�L‰L×#Ñ#Ô%ð	Ø—<‘<×0Ñ0×AÑAÜ�d×)Ñ)Ó*óð �J‰J�LøˆD�J‰J�Lús   ²7A: Á:B)rf   r¯   ©rf   N)rå   ræ   rç   rè   rî   r   Ú__annotations__r&   rM   ró   rû   rT   Úintr   ré   r  r÷   rQ   r  r�   r   r¦   r©   r«   r­   r   r»   r€   rN   rL   r¯   r¯   Î  s×   … ñð (-Ð�g˜e‘nÓ,ð˜}ó óòòð(˜ó (ð˜$ó ó!óóò>ð< Sð <°Cð <¸Có <ð< ð <°ð <¸ó <ð< Sð <°Cð <¸Có <ð<¨ð <¸ð <Àó <ð
˜˜c™ô 
rN   r¯   c                   ó  — e Zd ZdZdefd„Zdd„Zdd„Zdd„Zdd	„Z	e
defd
„«       Zd„ Zdeez  deddfd„Zd„ Zdeez  deddfd„Zd„ Zdeez  deddfd„Zd„ Z	 d dedefd„Z	 d dedefd„Z	 	 	 	 d!dededee   deddf
d„Zy)"r·   z2
    PubSub object for multi database client.
    r~   c                 ó^   — || _          | j                   j                  j                  di |¤Ž y)zýInitialize the PubSub object for a multi-database client.

        Args:
            client: MultiDBClient instance to use for pub/sub operations
            **kwargs: Additional keyword arguments to pass to the underlying pubsub implementation
        Nr€   )rñ   rD   r¸   )rK   r~   r¡   s      rL   rM   zPubSub.__init__(  s(   € ð ˆŒØ,ˆ�‰×%Ñ%×,Ñ,Ñ6¨vÓ6rN   rf   c                 ó   — | S rP   r€   rS   s    rL   ró   zPubSub.__enter__3  rô   rN   Nc                 óD   — 	 | j                  «        y # t        $ r Y y w xY wrP   rþ   rS   s    rL   rT   zPubSub.__del__6  s$   € ð	ð �J‰J�LøÜò 	Ùð	úrU   c                 óL   — | j                   j                  j                  d«      S )Nr÷   ©rñ   rD   Úexecute_pubsub_methodrS   s    rL   r÷   zPubSub.reset?  s   € Ø�|‰|×,Ñ,×BÑBÀ7ÓKÐKrN   c                 ó$   — | j                  «        y rP   rö   rS   s    rL   rQ   zPubSub.closeB  rü   rN   c                 óV   — | j                   j                  j                  j                  S rP   )rñ   rD   Úactive_pubsubÚ
subscribedrS   s    rL   r  zPubSub.subscribedE  s   € à�|‰|×,Ñ,×:Ñ:×EÑEÐErN   c                 óP   —  | j                   j                  j                  dg|¢­Ž S )Nr�   r  ©rK   rŸ   s     rL   r�   zPubSub.execute_commandI  s,   € ØBˆt�|‰|×,Ñ,×BÑBØð
Ø $ò
ð 	
rN   rŸ   r¡   c                 óV   —  | j                   j                  j                  dg|¢­i |¤ŽS )aE  
        Subscribe to channel patterns. Patterns supplied as keyword arguments
        expect a pattern name as the key and a callable as the value. A
        pattern's callable will be invoked automatically when a message is
        received on that pattern rather than producing a message via
        ``listen()``.
        Ú
psubscriber  r¥   s      rL   r"  zPubSub.psubscribeN  ó7   € ð Cˆt�|‰|×,Ñ,×BÑBØð
Øò
Ø#)ñ
ð 	
rN   c                 óP   —  | j                   j                  j                  dg|¢­Ž S )zj
        Unsubscribe from the supplied patterns. If empty, unsubscribe from
        all patterns.
        Úpunsubscriber  r   s     rL   r%  zPubSub.punsubscribe\  ó/   € ð
 Cˆt�|‰|×,Ñ,×BÑBØð
Ø!ò
ð 	
rN   c                 óV   —  | j                   j                  j                  dg|¢­i |¤ŽS )aR  
        Subscribe to channels. Channels supplied as keyword arguments expect
        a channel name as the key and a callable as the value. A channel's
        callable will be invoked automatically when a message is received on
        that channel rather than producing a message via ``listen()`` or
        ``get_message()``.
        Ú	subscriber  r¥   s      rL   r(  zPubSub.subscribee  s7   € ð Cˆt�|‰|×,Ñ,×BÑBØð
Øò
Ø"(ñ
ð 	
rN   c                 óP   —  | j                   j                  j                  dg|¢­Ž S )zi
        Unsubscribe from the supplied channels. If empty, unsubscribe from
        all channels
        Úunsubscriber  r   s     rL   r*  zPubSub.unsubscribes  s(   € ð
 Cˆt�|‰|×,Ñ,×BÑBÀ=ÐXÐSWÒXÐXrN   c                 óV   —  | j                   j                  j                  dg|¢­i |¤ŽS )az  
        Subscribes the client to the specified shard channels.
        Channels supplied as keyword arguments expect a channel name as the key
        and a callable as the value. A channel's callable will be invoked automatically
        when a message is received on that channel rather than producing a message via
        ``listen()`` or ``get_sharded_message()``.
        Ú
ssubscriber  r¥   s      rL   r,  zPubSub.ssubscribez  r#  rN   c                 óP   —  | j                   j                  j                  dg|¢­Ž S )zu
        Unsubscribe from the supplied shard_channels. If empty, unsubscribe from
        all shard_channels
        Úsunsubscriber  r   s     rL   r.  zPubSub.sunsubscribeˆ  r&  rN   Úignore_subscribe_messagesÚtimeoutc                 óR   — | j                   j                  j                  d||¬«      S )a  
        Get the next message if one is available, otherwise None.

        If timeout is specified, the system will wait for `timeout` seconds
        before returning. Timeout should be specified as a floating point
        number, or None, to wait indefinitely.
        Úget_message©r/  r0  r  ©rK   r/  r0  s      rL   r2  zPubSub.get_message‘  s0   € ð �|‰|×,Ñ,×BÑBØØ&?Øð Có 
ð 	
rN   c                 óR   — | j                   j                  j                  d||¬«      S )a&  
        Get the next message if one is available in a sharded channel, otherwise None.

        If timeout is specified, the system will wait for `timeout` seconds
        before returning. Timeout should be specified as a floating point
        number, or None, to wait indefinitely.
        Úget_sharded_messager3  r  r4  s      rL   r6  zPubSub.get_sharded_message¡  s0   € ð �|‰|×,Ñ,×BÑBØ!Ø&?Øð Có 
ð 	
rN   Ú
sleep_timeÚdaemonÚexception_handlerÚsharded_pubsubr   c                 óV   — | j                   j                  j                  |||| |¬«      S )N)r8  r9  r¸   r:  )rñ   rD   Úexecute_pubsub_run)rK   r7  r8  r9  r:  s        rL   Úrun_in_threadzPubSub.run_in_thread±  s6   € ð �|‰|×,Ñ,×?Ñ?ØØØ/ØØ)ð @ó 
ð 	
rN   )rf   r·   r  )Fç        )r>  FNF)rå   ræ   rç   rè   r&   rM   ró   rT   r÷   rQ   Úpropertyré   r  r�   r!   r#   r"   r"  r%  r(  r*  r,  r.  rê   r2  r6  r   r   r=  r€   rN   rL   r·   r·   #  sA  „ ñð	7˜}ó 	7óóóLóð ðF˜Dò Fó ðFò
ð

Ø Ñ,ð
Ø8Eð
à	ó
ò
ð
Ø Ñ,ð
Ø8Eð
à	ó
òYð
Ø Ñ,ð
Ø8Eð
à	ó
ò
ð ILñ
Ø)-ð
Ø@Eó
ð" ILñ
Ø)-ð
Ø@Eó
ð$  ØØ04Ø$ñ
àð
ð ð
ð $ HÑ-ð	
ð
 ð
ð 
ô
rN   r·   )?rÂ   ÚloggingrG   Útypingr   r   r   r   r   Ú!redis.asyncio.multidb.healthcheckr   r	   Úredis.backgroundr
   Úredis.backoffr   Úredis.clientr   Úredis.commandsr   r   Úredis.exceptionsr   Úredis.maint_notificationsr   Úredis.multidb.circuitr   r   r_   Úredis.multidb.command_executorr   Úredis.multidb.configr   r   r   r   Úredis.multidb.databaser   r   r   Úredis.multidb.exceptionr   r   r   Úredis.multidb.failure_detectorr   Úredis.observability.attributesr   Úredis.retryr    Úredis.typingr!   r"   r#   Úredis.utilsr$   Ú	getLoggerrå   rÈ   r&   rá   r¯   r·   r€   rN   rL   ú<module>rT     sÄ   ðÛ Û Û ß 9Õ 9ç LÝ 0Ý #Ý +ß <Ý &Ý >Ý 0Ý 2Ý A÷ó ÷ EÑ D÷ñ õ
 ;Ý <Ý ß >Ñ >Ý $à	ˆ×	Ñ	˜8Ó	$€ð ôaAÐ'¨ó aAó ðaAðH& ó &ôRÐ" Lô R÷j[
ò [
rN   