Ë
    UV.j®"  ã                  ól  — d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZmZ dd	lmZ d
dlmZ 	 ddlmZ 	 ddlmZmZ ej2                  D � ci c]  }  e| «      d“Œ c} Z G d„ dej8                  «      Z G d„ dej:                  «      Zy# e$ r dZY Œ^w xY w# e$ r dZdZY Œdw xY wc c} w )až  Azure Storage Queues transport module for kombu.

More information about Azure Storage Queues:
https://azure.microsoft.com/en-us/services/storage/queues/

Features
========
* Type: Virtual
* Supports Direct: *Unreviewed*
* Supports Topic: *Unreviewed*
* Supports Fanout: *Unreviewed*
* Supports Priority: *Unreviewed*
* Supports TTL: *Unreviewed*

Connection String
=================

Connection string has the following formats:

.. code-block::

    azurestoragequeues://<STORAGE_ACCOUNT_ACCESS_KEY>@<STORAGE_ACCOUNT_URL>
    azurestoragequeues://<SAS_TOKEN>@<STORAGE_ACCOUNT_URL>
    azurestoragequeues://DefaultAzureCredential@<STORAGE_ACCOUNT_URL>
    azurestoragequeues://ManagedIdentityCredential@<STORAGE_ACCOUNT_URL>

Note that if the access key for the storage account contains a forward slash
(``/``), it will have to be regenerated before it can be used in the connection
URL.

.. code-block::

    azurestoragequeues://DefaultAzureCredential@<STORAGE_ACCOUNT_URL>
    azurestoragequeues://ManagedIdentityCredential@<STORAGE_ACCOUNT_URL>

If you wish to use an `Azure Managed Identity` you may use the
``DefaultAzureCredential`` format of the connection string which will use
``DefaultAzureCredential`` class in the azure-identity package. You may want to
read the `azure-identity documentation` for more information on how the
``DefaultAzureCredential`` works.

.. _azure-identity documentation:
https://learn.microsoft.com/en-us/python/api/overview/azure/identity-readme?view=azure-python
.. _Azure Managed Identity:
https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview

Transport Options
=================

* ``queue_name_prefix``
é    )ÚannotationsN)ÚEmpty)ÚAny)ÚResourceExistsError)Úsafe_str)ÚdumpsÚloads)Úcached_propertyé   )Úvirtual)ÚQueueServiceClient)ÚDefaultAzureCredentialÚManagedIdentityCredentialé-   c                  óô   ‡ — e Zd ZU dZdZded<   dZded<   i Zded	<   d
Zded<    e	«       Z
ded<   ˆ fd„Zˆ fd„Zefdd„Zd„ Zd„ Zd„ Zdd„Zd„ Zd„ Zedd„«       Zed„ «       Zed„ «       Zedd„«       Zˆ xZS )ÚChannelzAzure Storage Queues channel.zkombu%(vhost)sÚstrÚdomain_formatNzQueueServiceClient | NoneÚ_queue_servicezdict[Any, Any]Ú_queue_name_cacheTÚboolÚno_ackzset[Any]Ú_noack_queuesc                ó  •— t         €t        d«      ‚t        ‰| �  |i |¤Ž t        j                  | j                  j                  «      \  | _        | _	        | j                  j                  «       D ]  }|| j                  |d   <   Œ y )NzGAzure Storage Queues transport requires the azure-storage-queue libraryÚname)r   ÚImportErrorÚsuperÚ__init__Ú	TransportÚ	parse_uriÚconninfoÚhostnameÚ_credentialÚ_urlÚqueue_serviceÚlist_queuesr   )ÚselfÚargsÚkwargsÚqueueÚ	__class__s       €údC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\kombu/transport/azurestoragequeues.pyr   zChannel.__init___   s…   ø€ ÜÐ%Üð <ó =ð =ô 	‰Ñ˜$Ð) &Ò)ä&/×&9Ñ&9Ø�M‰M×"Ñ"ó'
Ñ#ˆÔ˜$œ)ð ×'Ñ'×3Ñ3Ö5ˆEØ49ˆD×"Ñ" 5¨¡=Ò1ñ 6ó    c                óf   •— |r| j                   j                  |«       t        ‰| �  ||g|¢­i |¤ŽS ©N)r   Úaddr   Úbasic_consume)r'   r*   r   r(   r)   r+   s        €r,   r1   zChannel.basic_consumem   s@   ø€ ÙØ×Ñ×"Ñ" 5Ô)ä‰wÑ$ U¨Fð 6Ø&*ò6Ø.4ñ6ð 	6r-   c                óH   — t        t        |«      «      j                  |«      S )z=Format AMQP queue name into a valid Azure Storage Queue name.)r   r   Ú	translate)r'   r   Útables      r,   Úentity_namezChannel.entity_namet   s   € ä”8˜D“>Ó"×,Ñ,¨UÓ3Ð3r-   c                ó€  — | j                  | j                  |z   «      }	 | j                  j                  | j                  |   ¬«      }|S # t
        $ ri 	 | j                  j                  |«      }n+# t        $ r | j                  j                  |¬«      }Y nw xY w|j                  «       | j                  |<   Y |S w xY w)zEnsure a queue exists.)r*   )
r5   Úqueue_name_prefixr   Úget_queue_clientr   ÚKeyErrorr%   Úcreate_queuer   Úget_queue_properties©r'   r*   Úqs      r,   Ú_ensure_queuezChannel._ensure_queuex   sÌ   € à× Ñ  ×!7Ñ!7¸%Ñ!?Ó@ˆð
	EØ×#Ñ#×4Ñ4Ø×,Ñ,¨UÑ3ð 5ó ˆAð ˆøô ò 	EðFØ×&Ñ&×3Ñ3°EÓ:‘øÜ&ò FØ×'Ñ'×8Ñ8¸uÐ8ÓE’ðFúð -.×,BÑ,BÓ,DˆD×"Ñ" 5Ò)Øˆð	Eús5    )A Á	B=ÁA1Á0B=Á1%BÂB=ÂBÂ B=Â<B=c                ó”   — | j                  |«      }| j                  j                  |d«       | j                  j	                  |«       y)zDelete queue by name.N)r5   r   Úpopr%   Údelete_queue)r'   r*   r(   r)   Ú
queue_names        r,   Ú_deletezChannel._deleteˆ   s<   € à×%Ñ% eÓ,ˆ
Ø×Ñ×"Ñ" :¨tÔ4Ø×Ñ×'Ñ'¨
Õ3r-   c                ó^   — | j                  |«      }t        |«      }|j                  |«       y)zPut message onto queue.N)r>   r   Úsend_message)r'   r*   Úmessager)   r=   Úencoded_messages         r,   Ú_putzChannel._putŽ   s'   € à×Ñ˜uÓ%ˆÜ ›.ˆØ	�‰�Õ'r-   c                óâ   — | j                  |«      }|j                  d|¬«      }	 t        |«      }t        |j                  «      }|j                  |¬«       |S # t        $ r t	        «       ‚w xY w)z/Try to retrieve a single message off ``queue``.r   )Úmessages_per_pageÚtimeout)rF   )r>   Úreceive_messagesÚnextÚStopIterationr   r	   ÚcontentÚdelete_message)r'   r*   rK   r=   ÚmessagesrF   rO   s          r,   Ú_getzChannel._get”   ss   € à×Ñ˜uÓ%ˆà×%Ñ%¸À7Ð%ÓKˆð	Ü˜8“nˆGô ˜Ÿ™Ó(ˆà	×Ñ ÐÔ)àˆøô ò 	Ü“'ˆMð	ús   ¦A ÁA.c                óX   — | j                  |«      }|j                  «       j                  S )z)Return the number of messages in a queue.)r>   r;   Úapproximate_message_countr<   s      r,   Ú_sizezChannel._size¤   s'   € à×Ñ˜uÓ%ˆØ×%Ñ%Ó'×AÑAÐAr-   c                ó~   — | j                  |«      }| j                  |j                  «      }|j                  «        |S )z'Delete all current messages in a queue.)r>   rU   rB   Úclear_messages)r'   r*   r=   Úns       r,   Ú_purgezChannel._purge©   s5   € à×Ñ˜uÓ%ˆØ�J‰J�q—|‘|Ó$ˆØ	×ÑÔØˆr-   c                ó~   — | j                   €&t        | j                  | j                  ¬«      | _         | j                   S )N)Úaccount_urlÚ
credential)r   r   r$   r#   ©r'   s    r,   r%   zChannel.queue_service°   s8   € à×ÑÐ&Ü"4Ø ŸI™I°$×2BÑ2Bô#ˆDÔð ×"Ñ"Ð"r-   c                ó.   — | j                   j                  S r/   )Ú
connectionÚclientr]   s    r,   r!   zChannel.conninfo¹   s   € à�‰×%Ñ%Ð%r-   c                óB   — | j                   j                  j                  S r/   )r_   r`   Útransport_optionsr]   s    r,   rb   zChannel.transport_options½   s   € à�‰×%Ñ%×7Ñ7Ð7r-   c                ó:   — | j                   j                  dd«      S )Nr7   Ú )rb   Úgetr]   s    r,   r7   zChannel.queue_name_prefixÁ   s   € à×%Ñ%×)Ñ)Ð*=¸rÓBÐBr-   )Úreturnr   r/   )rf   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__r   r   r   Úsetr   r   r1   ÚCHARS_REPLACE_TABLEr5   r>   rC   rH   rR   rU   rY   Úpropertyr%   r!   rb   r
   r7   Ú__classcell__)r+   s   @r,   r   r   V   sÁ   ø… Ù'à)€M�3Ó)Ø04€NÐ-Ó4Ø(*Ð�~Ó*Ø€FˆDÓÙ!›e€M�8Ó#ô:ô6ð ':ô 4òò 4ò(óò Bò
ð ò#ó ð#ð ñ&ó ð&ð ñ8ó ð8ð òCó ôCr-   r   c                  óv   — e Zd ZU dZeZdZded<   dZded<   dZd	ed
<   e	dd„«       Z
e	 d	 	 	 	 	 	 	 dd„«       Zy)r   zAzure Storage Queues transport.r   ÚintÚpolling_intervalNz
int | NoneÚdefault_portTr   Úcan_parse_urlc                ó¸  — 	 | j                  dd«      } | j                  dd«      \  }}dj                  «       |j                  «       k(  rt        €t	        d«      ‚t        «       }nJdj                  «       |j                  «       k(  rt
        €t	        d«      ‚t        «       }nd	|v r	d
|vrd	|dœ}t        ||g«      sJ ‚	 ||fS # t        $ r t        d«      ‚w xY w)Nzazurestoragequeues://rd   Ú@r   r   z`Azure Storage Queues transport with a DefaultAzureCredential requires the azure-identity libraryr   zcAzure Storage Queues transport with a ManagedIdentityCredential requires the azure-identity libraryÚdevstoreaccount1z.core.windows.net)Úaccount_nameÚaccount_keyz¬Need a URI like azurestoragequeues://{SAS or access key}@{URL}, azurestoragequeues://DefaultAzureCredential@{URL}, , or azurestoragequeues://ManagedIdentityCredential@{URL})	ÚreplaceÚrsplitÚlowerr   r   r   ÚallÚ	ExceptionÚ
ValueError)Úurir\   Úurls      r,   r    zTransport.parse_uriÏ   s  € ð"	à—+‘+Ð5°rÓ:ˆCà!Ÿj™j¨¨aÓ0‰OˆJ˜à'×-Ñ-Ó/°:×3CÑ3CÓ3EÒEÜ)Ð1Ü%ð '?ó @ð @ô 4Ó5‘
Ø,×2Ñ2Ó4¸
×8HÑ8HÓ8JÒJÜ,Ð4Ü%ð '?ó @ð @ô 7Ó8‘
Ø# sÑ*Ð/BÈ#Ñ/Mð %7Ø#-ñ�
ô ˜
 CÐ(Ô)Ð)Ñ)ð ˜3ˆÐøô ò 	ÜðGóð ð	ús   ‚B=C ÃCc                ó`   — | j                  |«      \  }}dj                  |r||«      S ||«      S )Nzazurestoragequeues://{}@{})r    Úformat)Úclsr€   Úinclude_passwordÚmaskr\   r�   s         r,   Úas_urizTransport.as_uri   s?   € ð Ÿ-™-¨Ó,‰ˆ
�CØ+×2Ñ2Ù*ˆJ°có
ð 	
Ø04°có
ð 	
r-   )r€   r   rf   ztuple[str | dict, str])Fz**)r€   r   r…   r   r†   r   rf   r   )rg   rh   ri   rj   r   rr   rk   rs   rt   Ústaticmethodr    Úclassmethodr‡   © r-   r,   r   r   Æ   ss   … Ù)à€GàÐ�cÓØ#€L�*Ó#Ø€M�4Óàò.ó ð.ð` àCGð
Øð
Ø)-ð
Ø=@ð
à	ò
ó ñ
r-   r   )rj   Ú
__future__r   Ústringr*   r   Útypingr   Úazure.core.exceptionsr   Úkombu.utils.encodingr   Úkombu.utils.jsonr   r	   Úkombu.utils.objectsr
   rd   r   Úazure.storage.queuer   r   Úazure.identityr   r   ÚpunctuationÚordrm   r   r   )Úcs   0r,   Ú<module>r—      sÆ   ðñ2õh #ã Ý Ý å 5å )ß )Ý /å ðÝ6ð%÷;ð !×,Ò,óÙ,�Q�CˆƒFˆD�LÐ,ñÐ ô
mCˆg�o‰oô mCô`A
�×!Ñ!õ A
øðC ò ØÒðûð ò %Ø!ÐØ $Òð%üòs)   ºB ÁB" ÁB1ÂBÂBÂ"	B.Â-B.