hyb
2025-11-10 e0a856b5072c5a09f3f6de6da85abf90e00ee704
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º!ãóP—ddlmZmZddlmZmZmZddlZddlm    Z    ddl
m Z m Z m Z ddlmZmZddlmZddlmZmZdd    lmZmZmZdd
lmZmZdd lmZmZm Z m!Z!dd l"m#Z#m$Z$m%Z%m&Z&m'Z'dd l(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1dZ2defd„Z3eGd„d««Z4eGd„d««Z5y)é)Ú    dataclassÚfield)ÚListÚTypeÚUnionN)ÚOptional)ÚConnectionPoolÚRedisÚ RedisCluster)ÚExponentialWithJitterBackoffÚ    NoBackoff)Ú WeightedList)ÚEventDispatcherÚEventDispatcherInterface)ÚDEFAULT_GRACE_PERIODÚCircuitBreakerÚPBCircuitBreakerAdapter)ÚDatabaseÚ    Databases)ÚDEFAULT_FAILOVER_ATTEMPTSÚDEFAULT_FAILOVER_DELAYÚFailoverStrategyÚWeightBasedFailoverStrategy)ÚDEFAULT_FAILURE_RATE_THRESHOLDÚ!DEFAULT_FAILURES_DETECTION_WINDOWÚDEFAULT_MIN_NUM_FAILURESÚCommandFailureDetectorÚFailureDetector)ÚDEFAULT_HEALTH_CHECK_DELAYÚDEFAULT_HEALTH_CHECK_INTERVALÚDEFAULT_HEALTH_CHECK_POLICYÚDEFAULT_HEALTH_CHECK_PROBESÚ HealthCheckÚHealthCheckPoliciesÚPingHealthCheck)ÚRetryéxÚreturncó—t«S©N)r©óõgH:\项目\archive\测试组\脚本\Change_password\venv_build\Lib\site-packages\redis/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)Ú    pybreakerrr8r)ÚselfÚcircuit_breakers  r-Údefault_circuit_breakerz&DatabaseConfig.default_circuit_breakerRs#€Ü#×2Ñ2À×ARÑARÔSˆÜ& Ó7Ð7r,)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r1ÚfloatÚ__annotations__rÚdictr4r5rÚstrr6r    r7rrr8r9r?r+r,r-r0r00ss…ñð0€FˆEÓÙ°Ô5€M4Ó5Ø"€Hˆhs‰mÓ"Ø*.€Iˆx˜Ñ'Ó.Ø(,€GˆXnÑ %Ó,Ø.€L%Ó.Ø&*Аh˜s‘mÓ*ð8¨ô8r,r0cóš—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
)Ú MultiDbConfigaÚ
    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_probes_delay: Delay between health check attempts.
        health_check_policy: Policy for determining database health based on health checks.
        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_probes_delayÚhealth_check_policyÚfailover_strategyÚfailover_attemptsÚfailover_delayÚauto_fallback_intervalr2Ú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)rRrQ)Úconnection_pool)Úclientr7r1r9r+)rrJr4Úupdater&r r5rKr6Ú    set_retryr7r?Úaddrr1r9)r=Ú    databasesÚdatabase_configrer7s     r-rizMultiDbConfig.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ó\—t|j|j|j¬«gS)N)rUrVÚfailure_detection_window)rrUrVrW©r=s r-Údefault_failure_detectorsz'MultiDbConfig.default_failure_detectorsÀs/€ä "Ø!%×!6Ñ!6Ø'+×'BÑ'BØ)-×)GÑ)Gô ð
ð    
r,có—t«gSr*)r%rms r-Údefault_health_checksz#MultiDbConfig.default_health_checksÉs€ä Ó ð
ð    
r,có—t«Sr*)rrms r-Údefault_failover_strategyz'MultiDbConfig.default_failover_strategyÎs €Ü*Ó,Ð,r,)6r@rArBrCrr0rEr
rKrrr r&r rSrTrrrrUÚintrrVrDrrWrXr#r rYr"rZrr[r!r\r$r]rrr^rr_ÚDEFAULT_AUTO_FALLBACK_INTERVALr`rr.rarrrirnrprrr+r,r-rIrIWsG…ñ&ðP˜>Ñ*Ó*Ø5:€L$u˜U LÐ0Ñ1Ñ2Ó:Ù Ù,°!¸Ô<Àaô€M5óð:>Аx  _Ñ 5Ñ6Ó=Ø4АcÓ4Ø$BИEÓBØ'HИuÓHØ15€M8˜D Ñ-Ñ.Ó5Ø#@И5Ó@Ø:ИÓ:Ø'AИuÓAØ/JÐÐ,ÓJØ48АxР0Ñ1Ó8Ø6АsÓ6Ø2€NEÓ2Ø$BИEÓBÙ16Ø0ô2ÐÐ.óð'˜9ó'ðR
¨4°Ñ+@ó
ð
 t¨KÑ'8ó
ð
-Ð+;ô-r,rI)6Ú dataclassesrrÚtypingrrrr<Útyping_extensionsrÚredisr    r
r Ú redis.backoffr r Úredis.data_structurerÚ redis.eventrrÚredis.multidb.circuitrrrÚredis.multidb.databaserrÚredis.multidb.failoverrrrrÚredis.multidb.failure_detectorrrrrrÚredis.multidb.healthcheckrr r!r"r#r$r%Ú redis.retryr&rtr.r0rIr+r,r-ú<module>r‚s£ðß(ß$Ñ$ãÝ&ç5Ñ5ßAÝ-ßA÷ñ÷
7÷ó÷ õ÷÷ñõà!$ÐðÐ":óð ÷#8ð#8ó ð#8ðL ÷w-ðw-ó ñw-r,