+
     h7  c                   s   ^ RI t ^ RIt^ RIt^ RIHtHtHtHtHtH	t	H
t
 ^ RIHt ^ RIHtHtHtHt ^ RIHt ^ RIHtHtHtHt ^ RIHt  ! R R	]4      t ! R
 R]4      t ! R R]4      t ! R R]]4      t ! R R]4      t ! R R]4      t R# )    N)AsyncIteratorIterableMappingOptionalSequenceTupleType)Redis)
ConnectionConnectionPool
EncodableTSSLConnection)AsyncSentinelCommands)ConnectionErrorReadOnlyErrorResponseErrorTimeoutError)str_if_bytesc                   s    ] tR t^tRtR# )MasterNotFoundError N__name__
__module____qualname____firstlineno____static_attributes__r       ;/usr/lib/python3.14/site-packages/redis/asyncio/sentinel.pyr   r          r   r   c                   s    ] tR t^tRtR# )SlaveNotFoundErrorr   Nr   r   r   r   r   r      r   r   r   c                   sx   a a ] tR t^t oV 3R ltR tV 3R ltR tR tRRRR	R/V3R
 lV 3R llllt	Rt
VtV ;t# )SentinelManagedConnectionc                sT   < VP                  R 4      V n        \        SV `  ! R/ VB  R# )connection_poolNr   )popr    super__init__)selfkwargs	__class__s   &,r   r#   Z"SentinelManagedConnection.__init__   s%    %zz*;<"6"r   c                s    R V P                   P                   RV P                   P                   2pV P                  '       d%   RV P                   RV P                   2pW,          pVR,           # )<.z,host=z,port=z)>)r&   r   r   hostport)r$   ZsZ	host_info   &  r   __repr__Z"SentinelManagedConnection.__repr__   s]    ))*!DNN,C,C+DE999 6$))=INA4xr   c                s6  <"   Vw  V n         V n        \        SV `  4       G R j  xL
  V P                  P
                  '       dM   V P                  R4      G R j  xL
  \        V P                  4       G R j  xL
 4      R8w  d   \        R4      hR # R #  Ln L; L 5i)NZPINGZPONGzPING failed)
r)   r*   r"   connectr    check_connectionZsend_commandr   read_responser   )r$   Zaddressr&   s   &&r   
connect_toZ$SentinelManagedConnection.connect_to&   s     &	49go000##F+++$"4"4"6676A%m44 B 1 	 +6s9   !BBBBBB6B7BBBc                s  "   V P                   '       d   R # V P                  P                  '       d<   T P                  V P                  P	                  4       G R j  xL
 4      G R j  xL
  R # V P                  P                  4         R j  xL
  p V P                  V4      G R j  xL
 u #  LR LH L% L  \         d     K<  i ; iD:\        h5iN)Z_readerr    	is_masterr0   get_master_addressrotate_slavesr   r   )r$   slave   & r   _connect_retryZ(SentinelManagedConnection._connect_retry.   s     <<<)))//(<(<(O(O(Q"QRRR#33AAC  e!%!777	 #RR7&   D
 %$s|   0C(CB.C'B0( CCB2CCB6'B4(B6+C0C2C4B66CCC
Cc                sl   "   V P                   P                  V P                  R  4      G Rj  xL
 #  L5i)c                 s.    \         P                  ! ^ 4      # )r    )asyncioZsleep)Zerror   &r   Z<lambda>Z3SentinelManagedConnection.connect.<locals>.<lambda>>   s    '--*r   N)ZretryZcall_with_retryr7   r$   r9   r   r-   Z!SentinelManagedConnection.connect;   s2     ZZ//*
 
 	
 
s   +424Fdisconnect_on_errorTpush_requestc          	      sb   < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[ ,          /# )   disable_decodingtimeoutr;   r<   )boolr   ZfloatZformat__classdict__   "r   __annotate__Z&SentinelManagedConnection.__annotate__A   s?       %
 &e_ tnr   c               s   <"    \         SV `  VVVVR 7      G Rj  xL
 #  L  \         dC    T P                  P                  '       d%   T P                  4       G Rj  xL 
  \        R4      hh i ; i5i))r>   r?   r;   r<   Nz"The previous master is now a slave)r"   r/   r   r    r2   
disconnectr   )r$   r>   r?   r;   r<   r&   s   &&&$$r   r/   Z'SentinelManagedConnection.read_responseA   s{     	.!1$7)	 /      		##--- oo'''%&JKK		s7   A2"  " A2" &A/	A/AA//A2)r    r)   r*   )FN)r   r   r   r   r#   r,   r0   r7   r-   r/   r   __classdictcell____classcell__r&   rB      @@r   r   r      sA     #5%

 04 (-  r   r   c                   s    ] tR t^\tRtR# )SentinelManagedSSLConnectionr   Nr   r   r   r   rJ   rJ   \   r   r   rJ   c                   sx   a a ] tR t^`t oRtV 3R ltR tV 3R ltV3R lV 3R lltR t	V3R lR	 lt
R
tVtV ;t# )SentinelConnectionPoolz
Sentinel backed connection pool.

If ``check_connection`` flag is set to True, SentinelManagedConnection
sends a PING command right after establishing the connection.
c                sl  < TP                  R VP                  RR4      '       d   \        M\        4      VR &   VP                  RR4      V n        VP                  RR4      V n        \        SV `  ! R/ VB  \        P                  ! V 4      V P                  R&   Wn        W n        RV n        RV n        R# )	Zconnection_classZsslFr2   Tr.   r    Nr   )getr!   rJ   r   r2   r.   r"   r#   weakrefZproxyconnection_kwargsservice_namesentinel_managermaster_addressslave_rr_counter)r$   rO   rP   r%   r&   s   &&&,r   r#   ZSentinelConnectionPool.__init__h   s    %+ZZ ::eU++ -.&
!"  K6 &

+=u E"6"4;MM$4G01( 0" $r   c           	     s    R V P                   P                   RV P                   P                   RV P                   RV P                  ;'       d    R;'       g    R R2	# )r'   r(   z	(service=Z(Zmasterr5   z))>)r&   r   r   rO   r2   r:   r9   r   r,   ZSentinelConnectionPool.__repr__z   s\    ))*!DNN,C,C+D))*!DNN,G,Gx,R,R7+SSVX	
r   c                s@   < \         SV `  4        R V n        R V n        R # r1   )r"   resetrQ   rR   )r$   r&   s   &r   rS   ZSentinelConnectionPool.reset   s    " $r   c                    < V ^8  d   QhRS[ /# )r=   
connection)r	   rA   rC   r   rD   #SentinelConnectionPool.__annotate__   s     = =* =r   c                s   < V P                   '       * ;'       g:    V P                   ;'       d&    V P                  VP                  VP                  38H  pT;'       d    \        SV `  V4      # r1   )r2   rQ   r)   r*   r"   owns_connection)r$   rU   Zcheckr&   s   && r   rW   Z&SentinelConnectionPool.owns_connection   s]    NN" 
 
NNXXt22z
6XX 	 <<0<<r   c                s   "   V P                   P                  V P                  4      G R j  xL
 pV P                  '       d2   V P                  V8w  d!   Wn        V P                  RR7      G R j  xL
  V#  LI L5i)NF)Zinuse_connections)rP   discover_masterrO   r2   rQ   rE   )r$   rQ   r6   r   r3   Z)SentinelConnectionPool.get_master_address   sh     #44DDTEVEVWW>>>""n4&4# ooo>>> X ?s'   )A9A5A9,A9.A7/A97A9c                rT   )r=   return)r   rA   rC   r   rD   rV      s     N N] Nr   c               s0  "   V P                   P                  V P                  4      G Rj  xL
 pV'       d   V P                  f-   \        P
                  ! ^ \        V4      ^,
          4      V n        \        \        V4      4       FB  pV P                  ^,           \        V4      ,          V n        WP                  ,          pV5x  KD  	   V P                  4       G Rj  xL
 5x  \        RV P                  : 24      h L L"  \         d     L*i ; i5i)zRound-robin slave balancerNzNo slave found for )rP   discover_slavesrO   rR   randomZrandintlenZranger3   r   r   )r$   slavesZ_r5   s   &   r   r4   Z$SentinelConnectionPool.rotate_slaves   s     ,,<<T=N=NOO$$,(.q#f+/(J%3v;')-)>)>)Bc&k(Q%445 (
	//111 !#6t7H7H6K!LMM P 2" 		sK   )DDDBDD  D!D (DD DDDD)r.   r2   rQ   rP   rO   rR   )r   r   r   r   __doc__r#   r,   rS   rW   r3   r4   r   rF   rG   rH   rI   r   rK   rK   `   s:     %$
%
= =N N Nr   rK   c                   s   a  ] tR t^t o RtRR ltR tR tV 3R lR ltV 3R lR	 lt	V 3R
 lR lt
V 3R lR lt]]3V 3R lR llt]]3V 3R lR lltRtV tR# )Sentinela*  
Redis Sentinel cluster client

>>> from redis.sentinel import Sentinel
>>> sentinel = Sentinel([('localhost', 26379)], socket_timeout=0.1)
>>> master = sentinel.master_for('mymaster', socket_timeout=0.1)
>>> await master.set('foo', 'bar')
>>> slave = sentinel.slave_for('mymaster', socket_timeout=0.1)
>>> await slave.get('foo')
b'bar'

``sentinels`` is a list of sentinel nodes. Each node is represented by
a pair (hostname, port).

``min_other_sentinels`` defined a minimum number of peers for a sentinel.
When querying a sentinel, if it doesn't meet this threshold, responses
from that sentinel won't be considered valid.

``sentinel_kwargs`` is a dictionary of connection arguments used when
connecting to sentinel instances. Any argument that can be passed to
a normal Redis connection can be specified here. If ``sentinel_kwargs`` is
not specified, any socket_timeout and socket_keepalive options specified
in ``connection_kwargs`` will be used.

``connection_kwargs`` are keyword arguments that will be used when
establishing a connection to a Redis server.
Nc                s&   Vf=   VP                  4        UUu/ uF   w  rVVP                  R4      '       g   K  WVbK"  	  pppW0n        V UUu. uF  w  rx\        RRVRV/V P                  B NK   	  uppV n        W n        W@n        R # u uppi u uppi )NZsocket_r)   r*   r   )ZitemsZ
startswithsentinel_kwargsr   	sentinelsmin_other_sentinelsrN   )	r$   ra   rb   r`   rN   ZkZvZhostnamer*   s	   &&&&,    r   r#   ZSentinel.__init__   s     "!2!8!8!:!:all9>U!:    / #,
"+ CxCdCd.B.BC"+
 $7 !2

s   BB$Bc           
     s  "   \        VP                  RR4      4      pRVP                  4       9   d   VP                  R4       V'       d;   \        P
                  ! V P                  4      P                  ! V/ VB G Rj  xL
  R# V P                   Uu. uF)  p\        P                  ! VP                  ! V/ VB 4      NK+  	  pp\        P                  ! V!  G Rj  xL
  R#  Lcu upi  L5i)z
Execute Sentinel command in sentinel nodes.
once - If set to True, then execute the resulting command on a single
       node at random, rather than across the entire sentinel cluster.
onceFNT)r@   rL   Zkeysr!   r[   Zchoicera   execute_commandr8   ZTaskZgather)r$   Zargsr%   rc   sentinelZtaskss   &*,   r   rd   ZSentinel.execute_command   s      FJJvu-.V[[]"JJv--/??PPPP  !% .H X55tFvFG .   ..%((( Q )s6   A	C,3C,?C# C,/C%C,C*C,%C,c                s6   . pV P                    FO  pVP                  VP                  P                  R ,           RVP                  P                  R,           24       KQ  	  RV P                   RV P                  P
                   RRP                  V4       R2# )r)   Z:r*   r'   r(   z(sentinels=[Z,z])>)ra   appendr    rN   r&   r   join)r$   Zsentinel_addressesre   r+   r   r,   ZSentinel.__repr__   s    H%%++==fEFa++==fEFH ' q!8!8 9388$678=	
r   c                s,   < V ^8  d   QhRS[ RS[RS[/# )r=   staterO   rY   )dictstrr@   rA   rC   r   rD   Sentinel.__annotate__   s"       C D r   c                s    VR ,          '       d   VR,          '       g   VR,          '       d   R# VR,          V P                   8  d   R# R# )r2   is_sdownis_odownFznum-other-sentinelsT)rb   )r$   rh   rO   s   &&&r   check_master_stateZSentinel.check_master_state   s>    [!!U:%6%6%
:K:K&'$*B*BBr   c                rT   )r=   rO   )rj   rA   rC   r   rD   rk     s     W W# Wr   c                sV  "   \        4       p\        V P                  4       F  w  r4 VP                  4       G Rj  xL
 pTP                  T4      pT'       g   K9  T P                  Yq4      '       g   KR  TT P                  ^ ,          uT P                  ^ &   T P                  T&   TR,          TR,          3u # 	  Rp\        V4      ^ 8  d   RRP                  V4       2p\        RV: V 24      h L  \        \
        3 d#   pTP                  T RT: 24        Rp?K  Rp?ii ; i5i)	z
Asks sentinel servers for the Redis master's address corresponding
to the service labeled ``service_name``.

Returns a pair (address, port) or raises MasterNotFoundError if no
master is found.
Nz - ipr*   Z z : z, zNo master found for )ZlistZ	enumeratera   Zsentinel_mastersr   r   rf   rL   rn   r\   rg   r   )	r$   rO   Zcollected_errorsZsentinel_nore   ZmastersZerh   Z
error_infos	   &&       r   rX   ZSentinel.discover_master  s      6%.t~~%>!K ( 9 9 ;; KK-Eu00EE NN1% ?q!4>>+#> T{E&M11 &? 
 1$tyy)9:;<J!$88H"UVV! <#\2  ''8*Cu(=>sK   %D)C3C1C3 D)D)4A=D)1C33D&D!D)!D&&D)c                s\   < V ^8  d   QhRS[ S[,          RS[S[S[S[3,          ,          /# )r=   r]   rY   )r   r   r   r   r   rA   rC   r   rD   rk     s1     	 	w'		%
J./	0	r   c                s    . pV FD  pVR,          '       g   VR,          '       d   K#  VP                  VR,          VR,          34       KF  	  V# )z1Remove slaves that are in an ODOWN or SDOWN staterm   rl   ro   r*   )rf   )r$   r]   Zslaves_aliver5      &&  r   filter_slavesZSentinel.filter_slaves  sN     EZ  E*$5$5teFm <=  r   c                sL   < V ^8  d   QhRS[ RS[S[S[S[3,          ,          /# )r=   rO   rY   )rj   r   r   r   rA   rC   r   rD   rk   *  s,      	%
J./	0r   c                s   "   V P                    F:  p VP                  V4      G Rj  xL
 pT P                  T4      pT'       g   K8  Tu # 	  . #  L'  \        \        \        3 d     K[  i ; i5i)z;Returns a list of alive slaves for service ``service_name``N)ra   Zsentinel_slavesr   r   r   rq   )r$   rO   re   r]   rp   r   rZ   ZSentinel.discover_slaves*  sn      H'77EE ''/Fv ' 	 F#]LA s=   A.AAAA.A.AA+'A.*A++A.c                L   < V ^8  d   QhRS[ RS[S[,          RS[S[,          /# r=   rO   redis_classconnection_pool_classrj   r   r   rK   rA   rC   r   rD   rk   8  s3     #6 #6#6 %[#6  $$:;	#6r   c                    RVR&   \        V P                  4      pVP                  V4       V! W3/ VB pVP                  V4      # )a  
Returns a redis client instance for the ``service_name`` master.

A :py:class:`~redis.sentinel.SentinelConnectionPool` class is
used to retrieve the master's address before establishing a new
connection.

NOTE: If the master's address has changed, any cached connections to
the old master are closed.

By default clients will be a :py:class:`~redis.Redis` instance.
Specify a different class to the ``redis_class`` argument if you
desire something different.

The ``connection_pool_class`` specifies the connection pool to
use.  The :py:class:`~redis.sentinel.SentinelConnectionPool`
will be used by default.

All other keyword arguments are merged with any connection_kwargs
passed to this class and passed to the connection pool as keyword
arguments to be used to initialize Redis connections.
Tr2   ri   rN   ZupdateZ	from_poolr$   rO   rt   ru   r%   rN   r       &&&&,  r   
master_forZSentinel.master_for8  sN    : #{ !7!78  (/XFWX$$_55r   c                rr   rs   rv   rA   rC   r   rD   rk   ]  s3     6 66 %[6  $$:;	6r   c                rw   )a  
Returns redis client instance for the ``service_name`` slave(s).

A SentinelConnectionPool class is used to retrieve the slave's
address before establishing a new connection.

By default clients will be a :py:class:`~redis.Redis` instance.
Specify a different class to the ``redis_class`` argument if you
desire something different.

The ``connection_pool_class`` specifies the connection pool to use.
The SentinelConnectionPool will be used by default.

All other keyword arguments are merged with any connection_kwargs
passed to this class and passed to the connection pool as keyword
arguments to be used to initialize Redis connections.
Fr2   rx   ry   rz   r   	slave_forZSentinel.slave_for]  sN    0 ${ !7!78  (/XFWX$$_55r   )rN   rb   r`   ra   )r    N)r   r   r   r   r^   r#   rd   r,   rn   rX   rq   rZ   r   rK   r{   r|   r   rF   )rB   s   @r   r_   r_      sm     83,(

 W W:	 	 " $)>T	#6 #6P $)>T	6 6 6r   r_   )!r8   r[   rM   Ztypingr   r   r   r   r   r   r   Zredis.asyncio.clientr   Zredis.asyncio.connectionr	   r
   r   r   Zredis.commandsr   Zredis.exceptionsr   r   r   r   Zredis.utilsr   r   r   r   rJ   rK   r_   r   r   r   <module>r}      s       T T T &  1 X X $	/ 		 	?
 ?D	#<m 	DN^ DNNT6$ T6r   