
    ph<7                        S SK r S SKrS SKJrJr  S SKJr  S SKJrJ	r	J
r
JrJr  S SKJr  S SKJrJr   " S S\5      r " S	 S
\5      r " S S\5      r " S S\5      r " S S\5      r " S S5      r " S S\5      r " S S\5      r " S S5      r " S S5      r " S S5      r " S S5      r " S S 5      r " S! S"\5      r  " S# S$\5      r! " S% S&\5      r" " S' S(\5      r# " S) S*\5      r$ " S+ S,\5      r% " S- S.\5      r&g)/    N)ABCabstractmethod)Enum)DictListOptionalTypeUnion)TokenInterface)CredentialProviderStreamingCredentialProviderc                   0    \ rS rSrSr\S\4S j5       rSrg)EventListenerInterface   z/
Represents a listener for given event object.
eventc                     g N selfr   s     E/home/james-whalen/.local/lib/python3.13/site-packages/redis/event.pylistenEventListenerInterface.listen           r   N	__name__
__module____qualname____firstlineno____doc__r   objectr   __static_attributes__r   r   r   r   r      s"     F  r   r   c                   0    \ rS rSrSr\S\4S j5       rSrg)AsyncEventListenerInterface   z6
Represents an async listener for given event object.
r   c                    #    g 7fr   r   r   s     r   r   "AsyncEventListenerInterface.listen           r   Nr   r   r   r   r%   r%      s"     &  r   r%   c                       \ rS rSrSr\S\4S j5       r\S\4S j5       r\S\	\
\   \\\\4      4   4S j5       rSrg	)
EventDispatcherInterface   zZ
Represents a dispatcher that dispatches events to listeners
associated with given event.
r   c                     g r   r   r   s     r   dispatch!EventDispatcherInterface.dispatch%   r   r   c                    #    g 7fr   r   r   s     r   dispatch_async'EventDispatcherInterface.dispatch_async)   r)   r*   mappingsc                     g)zRegister additional listeners.Nr   )r   r4   s     r   register_listeners+EventDispatcherInterface.register_listeners-   s     	r   r   N)r   r   r   r    r!   r   r"   r/   r2   r   r	   r   r
   r   r%   r6   r#   r   r   r   r,   r,      s    
 f   &   L-/JJKLN
 r   r,   c                   8   ^  \ rS rSrSrS\S\4U 4S jjrSrU =r	$ )EventException9   zE
Exception wrapper that adds an event object into exception context.
	exceptionr   c                 <   > Xl         X l        [        TU ]  U5        g r   )r;   r   super__init__)r   r;   r   	__class__s      r   r>   EventException.__init__>   s    "
#r   )r   r;   )
r   r   r   r    r!   	Exceptionr"   r>   r#   __classcell__)r?   s   @r   r9   r9   9   s     $) $F $ $r   r9   c                       \ rS rSr SS\\\\   \\	   4      4S jjr
S\4S jrS\4S jrS\\\   \\\	\4      4   4S	 jrS
rg)EventDispatcherD   Nevent_listenersc                 :   [         [        5       /[        [        5       /[        [        5       /[        [        5       /[        [        5       /[        [        5       /0U l        [        R                  " 5       U l        SU l        U(       a  U R#                  U5        gg)zM
Dispatcher that dispatches events to listeners associated with given event.
N)AfterConnectionReleasedEventReAuthConnectionListener(AfterPooledConnectionsInstantiationEvent"RegisterReAuthForPooledConnections'AfterSingleConnectionInstantiationEvent!RegisterReAuthForSingleConnection'AfterPubSubConnectionInstantiationEventRegisterReAuthForPubSub#AfterAsyncClusterInstantiationEvent"RegisterReAuthForAsyncClusterNodes!AsyncAfterConnectionReleasedEventAsyncReAuthConnectionListener_event_listeners_mapping	threadingLock_lock_async_lockr6   )r   rF   s     r   r>   EventDispatcher.__init__F   s     )(*+ 5247 4136 46M6O5P/2T2V1W--/0
 	%& ^^%
##O4 r   r   c                     U R                      U R                  R                  [        U5      / 5      nU H  nUR	                  U5        M     S S S 5        g ! , (       d  f       g = fr   )rW   rT   gettyper   r   r   	listenerslisteners       r   r/   EventDispatcher.dispatchh   sE    ZZ5599$u+rJI%& & ZZs   A A
A$c                 r  #    U R                   c  [        R                  " 5       U l         U R                    IS h  vN   U R                  R	                  [        U5      / 5      nU H  nUR                  U5      I S h  vN   M     S S S 5      IS h  vN   g  N\ N N	! , IS h  vN  (       d  f       g = f7fr   )rX   asynciorV   rT   r[   r\   r   r]   s       r   r2   EventDispatcher.dispatch_asynco   s     #&||~D###5599$u+rJI%ooe,,, & $## -	 $###sV   8B7BB7?B=B>BB7BB7BB7B4#B&$B40B7r4   c           	         U R                      U HX  nX R                  ;   a5  [        [        U R                  U   X   -   5      5      U R                  U'   MG  X   U R                  U'   MZ     S S S 5        g ! , (       d  f       g = fr   )rW   rT   listset)r   r4   
event_types      r   r6   "EventDispatcher.register_listenersy   sy     ZZ&
!>!>>@D 99*E&23AD11*= AI@TD11*= ' ZZs   AA55
B)rX   rT   rW   r   )r   r   r   r    r   r   r	   r"   r   r   r>   r/   r2   r
   r%   r6   r#   r   r   r   rD   rD   D   s~     	 5!ft$:;;<
 5D'f '-& -UL-/JJKLN
Ur   rD   c                   .    \ rS rSrSrS r\S 5       rSrg)rH      z9
Event that will be fired before each command execution.
c                     Xl         g r   _connection)r   
connections     r   r>   %AfterConnectionReleasedEvent.__init__   s    %r   c                     U R                   $ r   rl   r   s    r   rn   'AfterConnectionReleasedEvent.connection       r   rl   N)	r   r   r   r    r!   r>   propertyrn   r#   r   r   r   rH   rH      s     &    r   rH   c                       \ rS rSrSrg)rR      r   Nr   r   r   r    r#   r   r   r   rR   rR          r   rR   c                       \ rS rSrSrSrSrg)
ClientType   )sync)asyncr   N)r   r   r   r    SYNCASYNCr#   r   r   r   rz   rz      s    DEr   rz   c                       \ rS rSrSr SS\S\S\\   4S jjr	\
S 5       r\
S	\4S
 j5       r\
S	\\S4   4S j5       rSrg)rJ      zI
Event that will be fired after pooled connection instances was created.
Nconnection_poolsclient_typecredential_providerc                 (    Xl         X l        X0l        g r   )_connection_pools_client_type_credential_provider)r   r   r   r   s       r   r>   1AfterPooledConnectionsInstantiationEvent.__init__   s     "2'$7!r   c                     U R                   $ r   )r   rq   s    r   r   9AfterPooledConnectionsInstantiationEvent.connection_pools   s    %%%r   returnc                     U R                   $ r   r   rq   s    r   r   4AfterPooledConnectionsInstantiationEvent.client_type          r   c                     U R                   $ r   r   rq   s    r   r   <AfterPooledConnectionsInstantiationEvent.credential_provider       (((r   )r   r   r   r   )r   r   r   r    r!   r   rz   r   r   r>   rt   r   r   r
   r   r#   r   r   r   rJ   rJ      s     =A	88  8 &&89	8 & & !Z ! ! )U+=t+C%D ) )r   rJ   c                       \ rS rSrSrS\S\\R                  \	R                  4   4S jr\S 5       r\S\4S j5       r\S\\R                  \	R                  4   4S	 j5       rS
rg)rL      z
Event that will be fired after single connection instances was created.

:param connection_lock: For sync client thread-lock should be provided,
for async asyncio.Lock
r   connection_lockc                 (    Xl         X l        X0l        g r   )rm   r   _connection_lock)r   rn   r   r   s       r   r>   0AfterSingleConnectionInstantiationEvent.__init__   s     &' /r   c                     U R                   $ r   rl   rq   s    r   rn   2AfterSingleConnectionInstantiationEvent.connection   rs   r   r   c                     U R                   $ r   r   rq   s    r   r   3AfterSingleConnectionInstantiationEvent.client_type   r   r   c                     U R                   $ r   r   rq   s    r   r   7AfterSingleConnectionInstantiationEvent.connection_lock       $$$r   )r   rm   r   N)r   r   r   r    r!   rz   r
   rU   RLockrb   rV   r>   rt   rn   r   r   r#   r   r   r   rL   rL      s    0  0 y<=	0     !Z ! ! %y'D!E % %r   rL   c                       \ rS rSrS\S\\R                  \R                  4   4S jr
\S 5       r\S 5       r\S\4S j5       r\S\\R                  \R                  4   4S	 j5       rS
rg)rN      r   r   c                 4    Xl         X l        X0l        X@l        g r   )_pubsub_connection_connection_poolr   r   )r   pubsub_connectionconnection_poolr   r   s        r   r>   0AfterPubSubConnectionInstantiationEvent.__init__   s     #4 /' /r   c                     U R                   $ r   )r   rq   s    r   r   9AfterPubSubConnectionInstantiationEvent.pubsub_connection   s    &&&r   c                     U R                   $ r   )r   rq   s    r   r   7AfterPubSubConnectionInstantiationEvent.connection_pool   r   r   r   c                     U R                   $ r   r   rq   s    r   r   3AfterPubSubConnectionInstantiationEvent.client_type   r   r   c                     U R                   $ r   r   rq   s    r   r   7AfterPubSubConnectionInstantiationEvent.connection_lock   r   r   )r   r   r   r   N)r   r   r   r    rz   r
   rU   r   rb   rV   r>   rt   r   r   r   r   r#   r   r   r   rN   rN      s    
0  	
0
 y<=
0 ' ' % % !Z ! ! %y'D!E % %r   rN   c                   p    \ rS rSrSr SS\S\\   4S jjr\	S\4S j5       r
\	S\\S4   4S	 j5       rS
rg)rP      z
Event that will be fired after async cluster instance was created.

Async cluster doesn't use connection pools,
instead ClusterNode object manages connections.
Nnodesr   c                     Xl         X l        g r   )_nodesr   )r   r   r   s      r   r>   ,AfterAsyncClusterInstantiationEvent.__init__  s    
 $7!r   r   c                     U R                   $ r   )r   rq   s    r   r   )AfterAsyncClusterInstantiationEvent.nodes  s    {{r   c                     U R                   $ r   r   rq   s    r   r   7AfterAsyncClusterInstantiationEvent.credential_provider  r   r   )r   r   r   )r   r   r   r    r!   dictr   r   r>   rt   r   r
   r   r#   r   r   r   rP   rP      sk     =A88 &&898 t   )U+=t+C%D ) )r   rP   c                   Z    \ rS rSrSrS\S\4S jr\S\4S j5       r	\S\4S j5       r
S	rg
)OnCommandsFailEventi  z<
Event fired whenever a command fails during the execution.
commandsr;   c                     Xl         X l        g r   	_commands
_exception)r   r   r;   s      r   r>   OnCommandsFailEvent.__init__  s    
 "#r   r   c                     U R                   $ r   )r   rq   s    r   r   OnCommandsFailEvent.commands"  s    ~~r   c                     U R                   $ r   )r   rq   s    r   r;   OnCommandsFailEvent.exception&  s    r   r   N)r   r   r   r    r!   tuplerA   r>   rt   r   r;   r#   r   r   r   r   r     sT    $$ $ %   9  r   r   c                       \ rS rSrSrg)AsyncOnCommandsFailEventi+  r   Nrw   r   r   r   r   r   +  rx   r   r   c                   &    \ rS rSrSrS\4S jrSrg)rI   i/  z?
Listener that performs re-authentication of given connection.
r   c                 8    UR                   R                  5         g r   rn   re_authr   s     r   r   ReAuthConnectionListener.listen4  s      "r   r   N)r   r   r   r    r!   rH   r   r#   r   r   r   rI   rI   /  s    #8 #r   rI   c                   &    \ rS rSrSrS\4S jrSrg)rS   i8  zE
Async listener that performs re-authentication of given connection.
r   c                 T   #    UR                   R                  5       I S h  vN   g  N7fr   r   r   s     r   r   $AsyncReAuthConnectionListener.listen=  s     &&(((s   (&(r   N)r   r   r   r    r!   rR   r   r#   r   r   r   rS   rS   8  s    )"C )r   rS   c                   T    \ rS rSrSrS rS\4S jrS rS r	S\
4S	 jrS\
4S
 jrSrg)rK   iA  z
Listener that registers a re-authentication callback for pooled connections.
Required by :class:`StreamingCredentialProvider`.
c                     S U l         g r   _eventrq   s    r   r>   +RegisterReAuthForPooledConnections.__init__G  	    r   r   c                    [        UR                  [        5      (       a  Xl        UR                  [
        R                  :X  aK  UR                  R                  U R                  5        UR                  R                  U R                  5        g UR                  R                  U R                  5        UR                  R                  U R                  5        g g r   )
isinstancer   r   r   r   rz   r~   on_next_re_authon_error_raise_on_error_re_auth_async_raise_on_error_asyncr   s     r   r   )RegisterReAuthForPooledConnections.listenJ  s    e//1LMMK  JOO3))11$--@))2243G3GH))11$2E2EF))2243M3MN Nr   c                 `    U R                   R                   H  nUR                  U5        M     g r   r   r   re_auth_callbackr   tokenpools      r   r   +RegisterReAuthForPooledConnections._re_authU  s$    KK00D!!%( 1r   c                 |   #    U R                   R                   H  nUR                  U5      I S h  vN   M     g  N	7fr   r   r   s      r   r   1RegisterReAuthForPooledConnections._re_auth_asyncY  s0     KK00D''... 1.s   .<:
<errorc                 ,    [        XR                  5      er   r9   r   r   r   s     r   r   2RegisterReAuthForPooledConnections._raise_on_error]      UKK00r   c                 4   #    [        XR                  5      e7fr   r   r   s     r   r   8RegisterReAuthForPooledConnections._raise_on_error_async`       UKK00   r   N)r   r   r   r    r!   r>   rJ   r   r   r   rA   r   r   r#   r   r   r   rK   rK   A  s=    
	OD 	O)/1Y 11 1r   rK   c                   T    \ rS rSrSrS rS\4S jrS rS r	S\
4S	 jrS\
4S
 jrSrg)rM   id  z
Listener that registers a re-authentication callback for single connection.
Required by :class:`StreamingCredentialProvider`.
c                     S U l         g r   r   rq   s    r   r>   *RegisterReAuthForSingleConnection.__init__j  r   r   r   c                    [        UR                  R                  [        5      (       a  Xl        UR
                  [        R                  :X  a_  UR                  R                  R                  U R                  5        UR                  R                  R                  U R                  5        g UR                  R                  R                  U R                  5        UR                  R                  R                  U R                  5        g g r   )r   rn   r   r   r   r   rz   r~   r   r   r   r   r   r   r   s     r   r   (RegisterReAuthForSingleConnection.listenm  s    002M
 
  K  JOO3  44<<T]]K  44==d>R>RS  44<<T=P=PQ  44==..
r   c                 4   U R                   R                     U R                   R                  R                  SUR	                  S5      UR                  5       5        U R                   R                  R                  5         S S S 5        g ! , (       d  f       g = fNAUTHoidr   r   rn   send_commandtry_get	get_valueread_responser   r   s     r   r   *RegisterReAuthForSingleConnection._re_auth|  sb    [[((KK""//e,eoo.? KK""002	 )((s   A)B		
Bc                   #    U R                   R                   IS h  vN   U R                   R                  R                  SUR	                  S5      UR                  5       5      I S h  vN   U R                   R                  R                  5       I S h  vN   S S S 5      IS h  vN   g  N NC N N! , IS h  vN  (       d  f       g = f7fr   r  r  s     r   r   0RegisterReAuthForSingleConnection._re_auth_async  s     ;;...++((55e,eoo.?   ++((66888	 /.. 9	 /...si   CB+CAB3)B-*+B3B/B3C%B1&C-B3/B31C3C
9B<:C
Cr   c                 ,    [        XR                  5      er   r   r   s     r   r   1RegisterReAuthForSingleConnection._raise_on_error  r   r   c                 4   #    [        XR                  5      e7fr   r   r   s     r   r   7RegisterReAuthForSingleConnection._raise_on_error_async  r   r   r   N)r   r   r   r    r!   r>   rL   r   r   r   rA   r   r   r#   r   r   r   rM   rM   d  s;    
C 391Y 11 1r   rM   c                   D    \ rS rSrS rS\4S jrS\4S jrS\	4S jr
S	rg
)rQ   i  c                     S U l         g r   r   rq   s    r   r>   +RegisterReAuthForAsyncClusterNodes.__init__  r   r   r   c                     [        UR                  [        5      (       aQ  Xl        UR                  R	                  U R
                  5        UR                  R                  U R                  5        g g r   )r   r   r   r   r   r   r   r   r   s     r   r   )RegisterReAuthForAsyncClusterNodes.listen  sS    e//1LMMK%%--dmm<%%..t/C/CD Nr   r   c                    #    U R                   R                   H3  nU R                   R                  U   R                  U5      I S h  vN   M5     g  N	7fr   )r   r   r   )r   r   keys      r   r   +RegisterReAuthForAsyncClusterNodes._re_auth  s?     ;;$$C++##C(99%@@@ %@s   AAA
Ar   c                 4   #    [        XR                  5      e7fr   r   r   s     r   r   2RegisterReAuthForAsyncClusterNodes._raise_on_error  r   r   r   N)r   r   r   r    r>   rP   r   r   r   rA   r   r#   r   r   r   rQ   rQ     s0    E? EAN A19 1r   rQ   c                   `    \ rS rSrS rS\4S jrS\4S jrS\4S jr	S\
4S	 jrS\
4S
 jrSrg)rO   i  c                 J    S U l         S U l        S U l        S U l        S U l        g r   )rm   r   r   r   r   rq   s    r   r>    RegisterReAuthForPubSub.__init__  s)     $  $r   r   c                    [        UR                  R                  [        5      (       GaF  UR                  R	                  5       S;   Ga&  Xl        UR                  U l        UR                  U l        UR                  U l
        UR                  U l        U R                  [        R                  :X  a_  U R                  R                  R                  U R                   5        U R                  R                  R#                  U R$                  5        g U R                  R                  R                  U R&                  5        U R                  R                  R#                  U R(                  5        g g g )N)   3)r   r   r   r   get_protocolr   rm   r   r   r   r   r   r   rz   r~   r   r   r   r   r   r   r   s     r   r   RegisterReAuthForPubSub.listen  s   ##779T
 
%%224@K$66D$)$9$9D! % 1 1D$)$9$9D!  JOO3  44<<T]]K  44==d>R>RS  44<<T=P=PQ  44==.. A
r   r   c                 .   U R                      U R                  R                  SUR                  S5      UR	                  5       5        U R                  R                  5         S S S 5        U R                  R                  U5        g ! , (       d  f       N*= fr   r   rm   r  r  r  r  r   r   r  s     r   r    RegisterReAuthForPubSub._re_auth  sn    ""))e,eoo.? **,	 # 	..u5 #"s   AB
Bc                   #    U R                    IS h  vN   U R                  R                  SUR                  S5      UR	                  5       5      I S h  vN   U R                  R                  5       I S h  vN   S S S 5      IS h  vN   U R                  R                  U5      I S h  vN   g  N N\ N< N.! , IS h  vN  (       d  f       NC= f N'7fr   r!  r  s     r   r   &RegisterReAuthForPubSub._re_auth_async  s     (((""//e,eoo.?   ""00222	 )( ##44U;;; ) 3	 )((( 	<st   CB0C>B8B2!B87B48B8<CB6"C*C+C2B84B86C8C>C?CCr   c                 ,    [        XR                  5      er   r   r   s     r   r   'RegisterReAuthForPubSub._raise_on_error  r   r   c                 4   #    [        XR                  5      e7fr   r   r   s     r   r   -RegisterReAuthForPubSub._raise_on_error_async  r   r   )r   rm   r   r   r   N)r   r   r   r    r>   rN   r   r   r   r   rA   r   r   r#   r   r   r   rO   rO     sD    C &6n 6<. <1Y 11 1r   rO   )'rb   rU   abcr   r   enumr   typingr   r   r   r	   r
   redis.auth.tokenr   redis.credentialsr   r   r   r%   r,   rA   r9   rD   rH   rR   rz   rJ   rL   rN   rP   r   r   rI   rS   rK   rM   rQ   rO   r   r   r   <module>r.     s     #  4 4 + MS # s 4$Y $FU. FUR
  
 	(D 	 
) )8% %>% %<) )2 ,	2 	#5 #)$? ) 1)?  1F*1(> *1Z1)? 1$114 11r   