hyb
2026-01-30 44480e71b27aa9d4cb8441f50c873f1b110e9691
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
83
84
85
86
87
Ë
 
çúh"ãóT—ddlmZmZddlmZmZmZmZddlZddl    m
Z
m Z m Z ddl mZmZddlmZmZmZmZddlmZmZddlmZmZmZmZmZmZmZdd    l m!Z!dd
l"m#Z#m$Z$dd l%m&Z&dd l'm(Z(m)Z)dd l*m+Z+m,Z,m-Z-ddl.m/Z/m0Z0m1Z1m2Z2dZ3de)fd„Z4eGd„d««Z5eGd„d««Z6y)é)Ú    dataclassÚfield)ÚListÚOptionalÚTypeÚUnionN)ÚConnectionPoolÚRedisÚ RedisCluster)ÚDatabaseÚ    Databases)ÚDEFAULT_FAILOVER_ATTEMPTSÚDEFAULT_FAILOVER_DELAYÚAsyncFailoverStrategyÚWeightBasedFailoverStrategy)ÚAsyncFailureDetectorÚFailureDetectorAsyncWrapper)ÚDEFAULT_HEALTH_CHECK_DELAYÚDEFAULT_HEALTH_CHECK_INTERVALÚDEFAULT_HEALTH_CHECK_POLICYÚDEFAULT_HEALTH_CHECK_PROBESÚ HealthCheckÚHealthCheckPoliciesÚPingHealthCheck)ÚRetry)ÚExponentialWithJitterBackoffÚ    NoBackoff)Ú WeightedList)ÚEventDispatcherÚEventDispatcherInterface)ÚDEFAULT_GRACE_PERIODÚCircuitBreakerÚPBCircuitBreakerAdapter)ÚDEFAULT_FAILURE_RATE_THRESHOLDÚ!DEFAULT_FAILURES_DETECTION_WINDOWÚDEFAULT_MIN_NUM_FAILURESÚCommandFailureDetectoréxÚreturncó—t«S©N)r©óõoH:\项目\archive\测试组\脚本\Change_password\venv_build\Lib\site-packages\redis/asyncio/multidb/config.pyÚdefault_event_dispatcherr/.s €Ü Ó Ðr-có¦—eZdZUdZdZeed<ee¬«Z    eed<dZ
e e ed<dZ e eed<dZe eed    <eZeed
<dZe e ed <d efd „Zy)ÚDatabaseConfigaÝ
    Dataclass representing the configuration for a database connection.
 
    This class is used to store configuration settings for a database connection,
    including client options, connection sourcing details, circuit breaker settings,
    and cluster-specific properties. It provides a structure for defining these
    attributes and allows for the creation of customized configurations for various
    database setups.
 
    Attributes:
        weight (float): Weight of the database to define the active one.
        client_kwargs (dict): Additional parameters for the database client connection.
        from_url (Optional[str]): Redis URL way of connecting to the database.
        from_pool (Optional[ConnectionPool]): A pre-configured connection pool to use.
        circuit (Optional[CircuitBreaker]): Custom circuit breaker implementation.
        grace_period (float): Grace period after which we need to check if the circuit could be closed again.
        health_check_url (Optional[str]): URL for health checks. Cluster FQDN is typically used
            on public Redis Enterprise endpoints.
 
    Methods:
        default_circuit_breaker:
            Generates and returns a default CircuitBreaker instance adapted for use.
    gð?Úweight©Údefault_factoryÚ client_kwargsNÚfrom_urlÚ    from_poolÚcircuitÚ grace_periodÚhealth_check_urlr)cóX—tj|j¬«}t|«S)N)Ú reset_timeout)Ú    pybreakerr"r9r#)ÚselfÚcircuit_breakers  r.Údefault_circuit_breakerz&DatabaseConfig.default_circuit_breakerTs#€Ü#×2Ñ2À×ARÑARÔSˆÜ& Ó7Ð7r-)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r2ÚfloatÚ__annotations__rÚdictr5r6rÚstrr7r    r8r"r!r9r:r@r,r-r.r1r12ss…ñð0€FˆEÓÙ°Ô5€M4Ó5Ø"€Hˆhs‰mÓ"Ø*.€Iˆx˜Ñ'Ó.Ø(,€GˆXnÑ %Ó,Ø.€L%Ó.Ø&*Аh˜s‘mÓ*ð8¨ô8r-r1cóš—eZdZUdZeeed<eZe    e
ee fed<e e dd¬«d¬«Ze ed    <d
Zeeeed <eZeed <eZeed <eZeed<d
Zeeeed<eZeed<eZeed<e Z!eed<e"Z#e$ed<d
Z%ee&ed<e'Z(eed<e)Z*eed<e+Z,eed<e-e.¬«Z/e0ed<de1fd„Z2deefd„Z3deefd„Z4de&fd„Z5y
)Ú MultiDbConfigaw
    Configuration class for managing multiple database connections in a resilient and fail-safe manner.
 
    Attributes:
        databases_config: A list of database configurations.
        client_class: The client class used to manage database connections.
        command_retry: Retry strategy for executing database commands.
        failure_detectors: Optional list of additional failure detectors for monitoring database failures.
        min_num_failures: Minimal count of failures required for failover
        failure_rate_threshold: Percentage of failures required for failover
        failures_detection_window: Time interval for tracking database failures.
        health_checks: Optional list of additional health checks performed on databases.
        health_check_interval: Time interval for executing health checks.
        health_check_probes: Number of attempts to evaluate the health of a database.
        health_check_delay: Delay between health check attempts.
        failover_strategy: Optional strategy for handling database failover scenarios.
        failover_attempts: Number of retries allowed for failover operations.
        failover_delay: Delay between failover attempts.
        auto_fallback_interval: Time interval to trigger automatic fallback.
        event_dispatcher: Interface for dispatching events related to database operations.
 
    Methods:
        databases:
            Retrieves a collection of database clients managed by weighted configurations.
            Initializes database clients based on the provided configuration and removes
            redundant retry objects for lower-level clients to rely on global retry logic.
 
        default_failure_detectors:
            Returns the default list of failure detectors used to monitor database failures.
 
        default_health_checks:
            Returns the default list of health checks used to monitor database health
            with specific retry and backoff strategies.
 
        default_failover_strategy:
            Provides the default failover strategy used for handling failover scenarios
            with defined retry and backoff configurations.
    Údatabases_configÚ client_classéé
)ÚbaseÚcapé)ÚbackoffÚretriesÚ command_retryNÚfailure_detectorsÚmin_num_failuresÚfailure_rate_thresholdÚfailures_detection_windowÚ health_checksÚhealth_check_intervalÚhealth_check_probesÚhealth_check_delayÚhealth_check_policyÚfailover_strategyÚfailover_attemptsÚfailover_delayÚauto_fallback_intervalr3Úevent_dispatcherr)c    óà—t«}|jD]S}|jjdt    dt «¬«i«|j r2|jj |j fi|j¤Ž}n}|jrU|jjt    dt «¬««|jj|j¬«}n|jdi|j¤Ž}|j€|j«n |j}|jt|||j|j¬«|j«ŒV|S)NÚretryr)rSrR)Úconnection_pool)Úclientr8r2r:r,)rrKr5Úupdaterrr6rLr7Ú    set_retryr8r@Úaddr r2r:)r>Ú    databasesÚdatabase_configrfr8s     r.rjzMultiDbConfig.databases˜sY€Ü “Nˆ    à#×4Ñ4ó"    ˆOð × )Ñ )× 0Ñ 0Øœ%¨´9³;Ô?Ð@ô ð×'Ò'Ø3˜×*Ñ*×3Ñ3Ø#×,Ñ,ñØ0?×0MÑ0Mñ‘ð!×*Ò*Ø×)Ñ)×3Ñ3Ü !¬Y«[Ô9ôð×*Ñ*×4Ñ4Ø$3×$=Ñ$=ð5ó‘ð+˜×*Ñ*ÑK¨_×-JÑ-JÑKð#×*Ñ*Ð2ð ×7Ñ7Ô9à$×,Ñ,ð ð
M‰MÜØ!Ø#Ø*×1Ñ1Ø%4×%EÑ%Eô    ð  ×&Ñ&ö ð5"    ðHÐr-cón—tt|j|j|j¬««gS)N)rVrWÚfailure_detection_window)rr'rVrWrX©r>s r.Údefault_failure_detectorsz'MultiDbConfig.default_failure_detectorsÁs7€ä 'Ü&Ø%)×%:Ñ%:Ø+/×+FÑ+FØ-1×-KÑ-Kôó ð
ð    
r-có—t«gSr+)rrns r.Údefault_health_checksz#MultiDbConfig.default_health_checksÌs€ä Ó ð
ð    
r-có—t«Sr+)rrns r.Údefault_failover_strategyz'MultiDbConfig.default_failover_strategyÑs €Ü*Ó,Ð,r-)6rArBrCrDrr1rFr
rLrrr rrrTrUrrr&rVÚintr$rWrEr%rXrYrrrZrr[rr\rr]rr^rrr_rr`ÚDEFAULT_AUTO_FALLBACK_INTERVALrarr/rbr r rjrorqrsr,r-r.rJrJYsJ…ñ%ðN˜>Ñ*Ó*Ø5:€L$u˜U LÐ0Ñ1Ñ2Ó:Ù Ù,°!¸Ô<Àaô€M5óð?CАx Ð%9Ñ :Ñ;ÓBØ4АcÓ4Ø$BИEÓBØ'HИuÓHØ15€M8˜D Ñ-Ñ.Ó5Ø#@И5Ó@Ø:ИÓ:Ø :ИÓ:Ø/JÐÐ,ÓJØ9=АxР5Ñ6Ó=Ø6АsÓ6Ø2€NEÓ2Ø$BИEÓBÙ16Ø0ô2ÐÐ.óð'˜9ó'ðR    
¨4Ð0DÑ+Eó    
ð
 t¨KÑ'8ó
ð
-Ð+@ô-r-rJ)7Ú dataclassesrrÚtypingrrrrr=Ú redis.asyncior    r
r Úredis.asyncio.multidb.databaser r Úredis.asyncio.multidb.failoverrrrrÚ&redis.asyncio.multidb.failure_detectorrrÚ!redis.asyncio.multidb.healthcheckrrrrrrrÚredis.asyncio.retryrÚ redis.backoffrrÚredis.data_structurerÚ redis.eventrr Úredis.multidb.circuitr!r"r#Úredis.multidb.failure_detectorr$r%r&r'rur/r1rJr,r-r.ú<module>rƒs¥ðß(ß.Ó.ãç=Ñ=ß>÷ó÷ ÷÷ñõ&ßAÝ-ßA÷ñ÷
óð"%ÐðÐ":óð ÷#8ð#8ó ð#8ðL ÷x-ðx-ó ñx-r-