1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Ë
 
çúhn.ãó6—ddlmZddlmZddlmZddlmZmZmZm    Z    m
Z
m Z ddl m Z ddlmZmZddlmZmZmZddlmZmZmZmZdd    lmZmZmZmZmZdd
l m!Z!dd l"m#Z#dd l$m%Z%m&Z&dd l'm(Z)ddl*m+Z+m,Z,ddl-m.Z.ddl/m0Z0Gd„de,«Z1Gd„de+e1«Z2y)é)Úabstractmethod)Úiscoroutinefunction)Údatetime)ÚAnyÚ    AwaitableÚCallableÚListÚOptionalÚUnion)Ú RedisCluster)ÚPipelineÚPubSub)Ú AsyncDatabaseÚDatabaseÚ    Databases)ÚAsyncActiveDatabaseChangedÚ&CloseConnectionOnActiveDatabaseChangedÚRegisterCommandFailureÚ"ResubscribeOnActiveDatabaseChanged)ÚDEFAULT_FAILOVER_ATTEMPTSÚDEFAULT_FAILOVER_DELAYÚAsyncFailoverStrategyÚDefaultFailoverStrategyExecutorÚFailoverStrategyExecutor)ÚAsyncFailureDetector)ÚRetry)ÚAsyncOnCommandsFailEventÚEventDispatcherInterface)ÚState)ÚBaseCommandExecutorÚCommandExecutor)ÚDEFAULT_AUTO_FALLBACK_INTERVAL)ÚKeyTcóÒ—eZdZeedefd„««Zeedeefd„««Z    ededdfd„«Z
eede e fd„««Z ede ddfd    „«Zeede efd
„««Zej"ed eddfd „««Zeedefd „««Zeedefd„««Zed„«Zed„«Zedefd„«Zedeegdffd„«Zedefd„«Zedede fd„«Z!y)ÚAsyncCommandExecutorÚreturncó—y)zReturns a list of databases.N©©Úselfs õyH:\项目\archive\测试组\脚本\Change_password\venv_build\Lib\site-packages\redis/asyncio/multidb/command_executor.pyÚ    databaseszAsyncCommandExecutor.databases ó€ð     ócó—y)z$Returns a list of failure detectors.Nr(r)s r+Úfailure_detectorsz&AsyncCommandExecutor.failure_detectors&r-r.Úfailure_detectorNcó—y)z=Adds a new failure detector to the list of failure detectors.Nr(©r*r1s  r+Úadd_failure_detectorz)AsyncCommandExecutor.add_failure_detector,s€ð     r.có—y)z"Returns currently active database.Nr(r)s r+Úactive_databasez$AsyncCommandExecutor.active_database1r-r.Údatabasecƒó K—y­w)z#Sets the currently active database.Nr()r*r7s  r+Úset_active_databasez(AsyncCommandExecutor.set_active_database7ó èø€ð     ùó‚có—y)z Returns currently active pubsub.Nr(r)s r+Ú active_pubsubz"AsyncCommandExecutor.active_pubsub<r-r.Úpubsubcó—y)zSets currently active pubsub.Nr(©r*r>s  r+r=z"AsyncCommandExecutor.active_pubsubBr-r.có—y)z#Returns failover strategy executor.Nr(r)s r+Úfailover_strategy_executorz/AsyncCommandExecutor.failover_strategy_executorHr-r.có—y)zReturns command retry object.Nr(r)s r+Ú command_retryz"AsyncCommandExecutor.command_retryNr-r.c‹ó K—y­w)z:Initializes a PubSub object on a currently active databaseNr(©r*Úkwargss  r+r>zAsyncCommandExecutor.pubsubTr:r;có K—y­w)z*Executes a command and returns the result.Nr()r*ÚargsÚoptionss   r+Úexecute_commandz$AsyncCommandExecutor.execute_commandYr:r;Ú command_stackcƒó K—y­w)z)Executes a stack of commands in pipeline.Nr()r*rLs  r+Úexecute_pipelinez%AsyncCommandExecutor.execute_pipeline^r:r;Ú transactioncó K—y­w)z1Executes a transaction block wrapped in callback.Nr()r*rOÚwatchesrJs    r+Úexecute_transactionz(AsyncCommandExecutor.execute_transactioncs èø€ð
     ùr;Ú method_namecó K—y­w)z*Executes a given method on active pub/sub.Nr()r*rSrIrGs    r+Úexecute_pubsub_methodz*AsyncCommandExecutor.execute_pubsub_methodjr:r;Ú
sleep_timec‹ó K—y­w)z!Executes pub/sub run in a thread.Nr()r*rVrGs   r+Úexecute_pubsub_runz'AsyncCommandExecutor.execute_pubsub_runor:r;)"Ú__name__Ú
__module__Ú __qualname__Úpropertyrrr,r    rr0r4r
rr6r9rr=ÚsetterrrBrrDr>rKÚtuplerNrr rRÚstrrUÚfloatrrXr(r.r+r%r%s„Ø Øð ˜9ò óóð ðØð  4Ð(<Ñ#=ò óóð ðð Ð5Ið Èdò óð ðØð  ¨-Ñ!8ò óóð ðð °-ð ÀDò óð ðØð ˜x¨Ñ/ò óóð ð×ÑØð  Fð ¨tò óóð ðØð Ð,Dò óóð ðØð ˜uò óóð ðñ óð ðñ óð ðð °Eò óð ðð Ø# X J°Ð$4Ñ5ò óð ð ð °sò óð ðð °5ð Àsò óñ r.r%cóꇗeZdZeeefdeedede    de
de de de de fˆfd    „ Zed
efd „«Zed
eefd „«Zd ed
dfd„Zed
eefd„«Zded
dfd„Zed
eefd„«Zej2ded
dfd„«Zed
efd„«Zed
e    fd„«Zd„Zd„Zdefd„Z ddddœde!dge"e#e$e#ffd e%d!ee&d"e'd#ee f
d$„Z(d%e&fd&„Z)    d1d'e d
e#fd(„Z*    d2d)e!d*efd+„Z+d,„Z,d-„Z-d.efd/„Z.d0„Z/ˆxZ0S)3ÚDefaultCommandExecutorr0r,rDÚfailover_strategyÚevent_dispatcherÚfailover_attemptsÚfailover_delayÚauto_fallback_intervalc    ó•—t‰
||«|D]}    |    j|¬«Œ||_||_||_t |||«|_||_d|_    d|_
i|_ |j«|j«y)a°
        Initialize the DefaultCommandExecutor instance.
 
        Args:
            failure_detectors: List of failure detector instances to monitor database health
            databases: Collection of available databases to execute commands on
            command_retry: Retry policy for failed command execution
            failover_strategy: Strategy for handling database failover
            event_dispatcher: Interface for dispatching events
            failover_attempts: Number of failover attempts
            failover_delay: Delay between failover attempts
            auto_fallback_interval: Time interval in seconds between attempts to fall back to a primary database
        )Úcommand_executorN)ÚsuperÚ__init__Úset_command_executorÚ
_databasesÚ_failure_detectorsÚ_command_retryrÚ_failover_strategy_executorÚ_event_dispatcherÚ_active_databaseÚ_active_pubsubÚ_active_pubsub_kwargsÚ_setup_event_dispatcherÚ_schedule_next_fallback) r*r0r,rDrcrdrerfrgÚfdÚ    __class__s           €r+rkzDefaultCommandExecutor.__init__vs›ø€ô0    ‰ÑÐ/Ô0à#ò    ;ˆBØ × #Ñ #°TÐ #Õ :ð    ;ð$ˆŒØ"3ˆÔØ+ˆÔÜ+JØ Ð0°.ó,
ˆÔ(ð"2ˆÔØ48ˆÔØ04ˆÔØ%'ˆÔ"Ø ×$Ñ$Ô&Ø ×$Ñ$Õ&r.r&có—|jS©N)rmr)s r+r,z DefaultCommandExecutor.databases s €à‰Ðr.có—|jSrz)rnr)s r+r0z(DefaultCommandExecutor.failure_detectors¤s€à×&Ñ&Ð&r.r1Ncó:—|jj|«yrz)rnÚappendr3s  r+r4z+DefaultCommandExecutor.add_failure_detector¨s€Ø ×Ñ×&Ñ&Ð'7Õ8r.có—|jSrz)rrr)s r+r6z&DefaultCommandExecutor.active_database«s€à×$Ñ$Ð$r.r7cƒóÌK—|j}||_|I||urD|jjt||j|fi|j¤Ž«ƒd{–—†yyy7Œ­wrz)rrrqÚdispatch_asyncrrt)r*r7Ú
old_actives   r+r9z*DefaultCommandExecutor.set_active_database¯syèø€Ø×*Ñ*ˆ
Ø (ˆÔà Ð ! j¸Ñ&@Ø×(Ñ(×7Ñ7Ü*ØØ×)Ñ)Øñð×0Ñ0ñ    ó÷ ñ ð'AÐ !ð ús‚AA$ÁA"ÁA$có—|jSrz©rsr)s r+r=z$DefaultCommandExecutor.active_pubsub½ó€à×"Ñ"Ð"r.r>có—||_yrzrƒr@s  r+r=z$DefaultCommandExecutor.active_pubsubÁs
€à$ˆÕr.có—|jSrz)rpr)s r+rBz1DefaultCommandExecutor.failover_strategy_executorÅs€à×/Ñ/Ð/r.có—|jSrz)ror)s r+rDz$DefaultCommandExecutor.command_retryÉr„r.c óà—|j€bt|jjt«r t d«‚|jjj di|¤Ž|_||_yy)Nz(PubSub is not supported for RedisClusterr()rsÚ
isinstancerrÚclientr Ú
ValueErrorr>rtrFs  r+r>zDefaultCommandExecutor.pubsubÍsa€Ø × Ñ Ð &ܘ$×/Ñ/×6Ñ6¼ ÔEÜ Ð!KÓLÐLà"E $×"7Ñ"7×">Ñ">×"EÑ"EÑ"OÈÑ"OˆDÔ Ø)/ˆDÕ &ð 'r.cóV‡‡‡K—ˆˆˆfd„}‰j|‰«ƒd{–—†S7Œ­w)Nc“ó¦•K—‰jjj‰i‰¤Žƒd{–—†}‰j‰«ƒd{–—†|S7Œ7Œ­wrz)rrrŠrKÚ_register_command_execution)ÚresponserIrJr*s €€€r+Úcallbackz8DefaultCommandExecutor.execute_command.<locals>.callbackÖs[øèø€ØI˜T×2Ñ2×9Ñ9×IÑIØðØ ñ÷ˆHð×2Ñ2°4Ó8× 8Ð 8؈Oð    øð 9ús!ƒ*A­A ®AÁAÁAÁA©Ú_execute_with_failure_detection)r*rIrJrs``` r+rKz&DefaultCommandExecutor.execute_commandÕs'úèø€ö    ð×9Ñ9¸(ÀDÓI×IÐIÐIús …)¢'£)rLcƒóR‡‡K—ˆˆfd„}‰j|‰«ƒd{–—†S7Œ­w)Nc“ó`•K—‰jjj«4ƒd{–—†}‰D]\}}|j|i|¤ŽŒ|j    «ƒd{–—†}‰j ‰«ƒd{–—†|cddd«ƒd{–—†S7Œd7Œ27Œ7Œ #1ƒd{–—†7swYyxYw­wrz)rrrŠÚpipelinerKÚexecuterŽ)ÚpipeÚcommandrJrrLr*s    €€r+rz9DefaultCommandExecutor.execute_pipeline.<locals>.callbackàsªøèø€Ø×,Ñ,×3Ñ3×<Ñ<Ó>÷  ð  À$Ø(5ò>Ñ$G˜WØ(D×(Ñ(¨'Ð=°WÓ=ð>ð"&§¡£×/Ø×6Ñ6°}ÓE×EÐEØ÷   ÷  ò  øð0øØEøð   ø÷  ÷  ñ  üshƒ)B.¬B­B.°0BÁ BÁ!BÁ9BÁ:BÁ? B. B B.ÂBÂBÂB.ÂB+ÂB"  B+Â'B.r‘)r*rLrs`` r+rNz'DefaultCommandExecutor.execute_pipelineßs'ùèø€õ     ð×9Ñ9¸(ÀMÓR×RÐRÐRús „' %¡'F©Ú
shard_hintÚvalue_from_callableÚ watch_delayÚfuncr rQršr›rœc‡ó`‡‡‡‡‡‡K—ˆˆˆˆˆˆfd„}‰j|«ƒd{–—†S7Œ­w)Nc“ó²•K—‰jjj‰g‰¢­‰‰‰dœŽƒd{–—†}‰jd«ƒd{–—†|S7Œ7Œ­w)Nr™r()rrrŠrOrŽ)rrr*ršr›rœrQs €€€€€€r+rz<DefaultCommandExecutor.execute_transaction.<locals>.callbackóskøèø€ØE˜T×2Ñ2×9Ñ9×EÑEØðàñð&Ø$7Ø'ò ÷ˆHð×2Ñ2°2Ó6× 6Ð 6؈Oðøð 7ús!ƒ0A³A´AÁ AÁ AÁAr‘)r*rršr›rœrQrs`````` r+rRz*DefaultCommandExecutor.execute_transactionës*ýèø€÷        ñ        ð×9Ñ9¸(ÓC×CÐCÐCús ˆ.§,¨.rScó\‡‡‡‡K—ˆˆˆˆfd„}‰j|g‰¢­Žƒd{–—†S7Œ­w)Nc“ó¾•K—t‰j‰«}t|«r|‰i‰¤Žƒd{–—†}n|‰i‰¤Ž}‰j‰«ƒd{–—†|S7Œ(7Œ­wrz)Úgetattrr=rrŽ)ÚmethodrrIrGrSr*s  €€€€r+rz>DefaultCommandExecutor.execute_pubsub_method.<locals>.callbacksføèø€Ü˜T×/Ñ/°Ó=ˆFÜ" 6Ô*Ù!'¨Ð!8°Ñ!8×8‘á! 4Ð2¨6Ñ2à×2Ñ2°4Ó8× 8Ð 8؈Oð 9øð 9ús!ƒ-A°A±!AÁAÁAÁAr‘)r*rSrIrGrs```` r+rUz,DefaultCommandExecutor.execute_pubsub_methods,ûèø€÷    ð:T×9Ñ9¸(ÐJÀTÒJ×JÐJÐJús †,¥*¦,rVcƒóX‡‡‡‡K—ˆˆˆˆfd„}‰j|«ƒd{–—†S7Œ­w)Nc“ó\•K—‰jj‰‰‰¬«ƒd{–—†S7Œ­w)N)Ú poll_timeoutÚexception_handlerr>)rsÚrun)r§r>r*rVs€€€€r+rz;DefaultCommandExecutor.execute_pubsub_run.<locals>.callbacks8øèø€Ø×,Ñ,×0Ñ0Ø'Ø"3Øð1ó÷ð ðús ƒ",¥*¦,r‘)r*rVr§r>rs```` r+rXz)DefaultCommandExecutor.execute_pubsub_run s%ûèø€÷    ð×9Ñ9¸(ÓC×CÐCÐCús †*£(¤*rÚcmdscƒóx‡‡‡‡K—ˆˆfd„Љjjˆfd„ˆˆfd„«ƒd{–—†S7Œ­w)zO
        Execute a commands execution callback with failure detection.
        c“ób•K—‰j«ƒd{–—†‰«ƒd{–—†S7Œ7Œ­wrz)Ú_check_active_database)rr*s€€r+ÚwrapperzGDefaultCommandExecutor._execute_with_failure_detection.<locals>.wrapper s-øèø€à×-Ñ-Ó/× /Ð /Ù!›×#Ð #ð 0øØ#úsƒ/—+˜/¦-§/­/có•—‰«Srzr()r­s€r+ú<lambda>zHDefaultCommandExecutor._execute_with_failure_detection.<locals>.<lambda>&s    ø€‘G“I€r.có*•—‰j|g‰¢­ŽSrz)Ú_on_command_fail)Úerrorr©r*s €€r+r¯zHDefaultCommandExecutor._execute_with_failure_detection.<locals>.<lambda>'sø€Ð/˜$×/Ñ/°Ð=¸Ò=€r.N)roÚcall_with_retry)r*rr©r­s```@r+r’z6DefaultCommandExecutor._execute_with_failure_detections7ûèø€õ    $ð
×(Ñ(×8Ñ8Û Ü =ó
÷
ð    
ð
ús †-:³8´:cƒóŒK—|je|jjjtjk7s4|j
t k7rl|jtj«krJ|j|jj«ƒd{–—†«ƒd{–—†|j«yyy7Œ#7Œ­w)zB
        Checks if active a database needs to be updated.
        N)rrÚcircuitÚstateÚCBStateÚCLOSEDÚ_auto_fallback_intervalr"Ú_next_fallback_attemptrÚnowr9rpr–rvr)s r+r¬z-DefaultCommandExecutor._check_active_database*sªèø€ð
× !Ñ !Ð )Ø×$Ñ$×,Ñ,×2Ñ2´g·n±nÒDà×,Ñ,Ô0NÒNØ×/Ñ/´8·<±<³>ÒAð×*Ñ*Ø×6Ñ6×>Ñ>Ó@×@ó÷ ð ð × (Ñ (Õ *ð BðOð
Aøð ús$‚BCÂC CÂ(CÂ)CÃCc‡ójK—|jjt||««ƒd{–—†y7Œ­wrz)rqr€r)r*r²rIs   r+r±z'DefaultCommandExecutor._on_command_fail;s.èø€Ø×$Ñ$×3Ñ3Ü $ T¨5Ó 1ó
÷    
ò    
ús ‚)3«1¬3ÚcmdcƒódK—|jD]}|j|«ƒd{–—†Œy7Œ­wrz)rnÚregister_command_execution)r*r½Údetectors   r+rŽz2DefaultCommandExecutor._register_command_execution@s2èø€Ø×/Ñ/ò    ;ˆHØ×5Ñ5°cÓ:× :Ñ :ñ    ;Ø :ús ‚$0¦.§0cóª—t|j«}t«}t«}|jj t |gt||gi«y)z0
        Registers necessary listeners.
        N)rrnrrrqÚregister_listenersrr)r*Úfailure_listenerÚresubscribe_listenerÚclose_connection_listeners    r+ruz.DefaultCommandExecutor._setup_event_dispatcherDsW€ô2°$×2IÑ2IÓJÐÜAÓCÐÜ$JÓ$LÐ!Ø ×Ñ×1Ñ1ä(Ð+;Ð*<Ü*Ø-Ø(ð-ð õ    
r.)NN)r()1rYrZr[rrr"r    rrrrrÚintr`rkr\r,r0r4r
rr6r9rr=r]rrBrDr>rKr^rNrr rrr#r_ÚboolrRrUrXr’r¬r±rŽruÚ __classcell__)rxs@r+rbrbusMø„ð";Ø 6Ø(Fñ('àР4Ñ5ð('ðð('ðð    ('ð
1ð ('ð 3ð ('ðð('ðð('ð!&õ('ðTð˜9òóððð' 4Ð(<Ñ#=ò'óð'ð9Ð5Ið9Èdó9ðð% ¨-Ñ!8ò%óð%ð °-ð ÀDó ðð#˜x¨Ñ/ò#óð#ð×Ñð% Fð%¨tò%óð%ðð0Ð,Dò0óð0ðð#˜uò#óð#ò0òJð
S°Eó
Sð %)Ø$)Ø'+ò Dà˜
| U¨3°    ¸#±Ð+>Ñ%?Ð?Ñ@ðDððDð˜S‘Mð    Dð
"ð Dð ˜e‘_ó Dð* K°só KðAEñ
DØð
Dà     ó
Dð13ñ
Ø ð
Ø(-ó
ò"+ò"
ð
;°Uó;ö
r.rbN)3ÚabcrÚasynciorrÚtypingrrrr    r
r Ú redis.asyncior Úredis.asyncio.clientr rÚredis.asyncio.multidb.databaserrrÚredis.asyncio.multidb.eventrrrrÚredis.asyncio.multidb.failoverrrrrrÚ&redis.asyncio.multidb.failure_detectorrÚredis.asyncio.retryrÚ redis.eventrrÚredis.multidb.circuitrr·Úredis.multidb.command_executorr r!Úredis.multidb.configr"Ú redis.typingr#r%rbr(r.r+ú<module>rØsmðÝÝ'ÝßB×Bå&ß1ßMÑM÷ó÷ õõHÝ%ßJÝ2ßOÝ?ÝôS ˜?ôS ôl^
Ð0Ð2Fõ^
r.