ó
    Ð]j  ã                  ó¦   • S r SSKJr  SSKrSSKrSSKJr  SSKJr	  SSK
JrJr  SSKJrJrJrJr   SSKr\R&                  " S	5      rSS
 jrSS jrg)z8
Separate connection attempts from a connection string.
é    )ÚannotationsN)Úshuffleé   )Úerrors)ÚConnDictÚConnMapping)Ú	get_paramÚget_param_defÚis_ip_addressÚsplit_attemptsÚpsycopgc              ƒ  ór  #   • Sn/ n[        U S5      S:H  =n(       a,  U R                  5        VVs0 s H  u  pEUS:w  d  M  XE_M     n nn[        U 5       H&  n UR                  [	        U5      I Sh  v•N 5        M(     U(       d  U(       d   eUe[        U S5      S	:X  a  [        U5        U(       a  U Vs/ s H  n0 UESS
0EPM     snU-   nU$ s  snnf  Nd! [
         aM  n[        R                  " SUR                  S5      < SU 35      n[        R                  SU5         SnAMÖ  SnAff = fs  snf 7f)aÞ  Split a set of connection params on the single attempts to perform.

A connection param can perform more than one attempt more than one ``host``
is provided.

Also perform async resolution of the hostname into hostaddr. Because a host
can resolve to more than one address, this can lead to yield more attempts
too. Raise `OperationalError` if no host could be resolved.

Because the libpq async function doesn't honour the timeout, we need to
reimplement the repeated attempts.
NÚtarget_session_attrszprefer-standbyzfailed to resolve host Úhostz: z%sÚload_balance_hostsÚrandomÚstandby)r	   Úitemsr   ÚextendÚ_resolve_hostnamesÚOSErrorÚeÚOperationalErrorÚgetÚloggerÚdebugr   )	ÚparamsÚlast_excÚattemptsÚprefer_standbyÚkÚvÚattemptÚexÚas	            Ú]/home/mande/repo/quber/.venv/lib/python3.13/site-packages/psycopg/_conninfo_attempts_async.pyÚconninfo_attempts_asyncr'      s;  é € ð €HØ€HÜ" 6Ð+AÓBÐFVÑVÐV€~ÕVØ#)§<¡<¤>ÔQ¢>™4˜1°QÐ:PÑ5P“$�!’$¡>ˆÑQä! &Ö)ˆð	)Ø�O‰OÔ"4°WÓ"=×=Ö>ñ *ö Þˆˆxàˆä�Ð-Ó.°(Ó:Ü�Ôö á>Fó
Ú>F¸Ð4ˆqÐ4Ð(¨)Ô4¹hñ
àñˆð €Oùó5 Rñ >øÜó 	)Ü×)Ò)Ø)¨'¯+©+°fÓ*=Ñ)@ÀÀ2À$ÐGóˆHô �L‰L˜˜x×(Ò(ûð		)üò"
ùs_   ‚.D7°CÁ CÁD7ÁCÁ1C
Á2CÁ:<D7Â6D2ÃD7ÃCÃ
D/Ã"AD*Ä$D7Ä*D/Ä/D7c              ƒ  ó(  #   • [        U S5      nU(       a  UR                  S5      (       d	  USS S:X  a  U /$ [        U S5      (       a  U /$ [        U5      (       a	  0 U ESU0E/$ [        U S5      =n(       d)  [        S5      nU=(       a    UR                  =(       d    Sn [
        R                  " 5       nUR                  X[        R                  [        R                  S	9I S
h  v•N nU Vs/ s H  n0 U ESUS   S   0EPM     sn$  N#s  snf 7f)a  
Perform async DNS lookup of the hosts and return a list of connection attempts.

If a ``host`` param is present but not ``hostname``, resolve the host
addresses asynchronously.

:param params: The input parameters, for instance as returned by
    `~psycopg.conninfo.conninfo_to_dict()`. The function expects at most
    a single entry for host, hostaddr because it is designed to further
    process the input of split_attempts().

:return: A list of attempts to make (to include the case of a hostname
    resolving to more than one IP).
r   Ú/r   é   Ú:ÚhostaddrÚportÚ5432)ÚprotoÚtypeNé   r   )r	   Ú
startswithr   r
   ÚcompiledÚasyncioÚget_running_loopÚgetaddrinfoÚsocketÚIPPROTO_TCPÚSOCK_STREAM)r   r   r-   Úport_defÚloopÚansÚitems          r&   r   r   D   s  é € ô �V˜VÓ$€DÞ�4—?‘? 3×'Ñ'¨4°°!¨9¸Ó+;àˆxˆä�˜×$Ñ$àˆxˆä�T×Ñà,�6Ð,˜: tÑ,Ð-Ð-ä˜f fÓ-Ð-ˆDÕ-Ü  Ó(ˆØ×-˜H×-Ñ-×7°ˆàÜ×'Ò'Ó)ˆØ×$Ñ$Øœf×0Ñ0´v×7IÑ7Ið %ð 
÷ 
ˆñ <?Ó?º3°4Ð.ˆvÐ.�z 4¨¡7¨1¡:Ô.¹3Ñ?Ð?ñ
ùò @ùs$   ‚C%DÃ'DÃ(DÃ0DÄDÄD)r   r   Úreturnúlist[ConnDict])r   r   r>   r?   )Ú__doc__Ú
__future__r   r7   Úloggingr   r   Ú r   r   Úabcr   r   Ú_conninfo_utilsr	   r
   r   r   r4   Ú	getLoggerr   r'   r   © ó    r&   Ú<module>rI      sF   ðñõ #ã Û Ý å ß &ß TÓ TàÛà	×	Ò	˜9Ó	%€ô*õZ*@rH   