o
    wvXja  ã                   @   sL   d Z ddlmZmZ ddlmZ ddlmZ dgZdd„ Z	G d	d„ dƒZ
d
S )z Amazon SQS queue implementation.é    )Úabsolute_importÚunicode_literals)Ú	transformé   )ÚAsyncMessageÚ
AsyncQueuec                 C   s   t | ƒdkr
| d S dS )z4Get the first item in a list, or None if list empty.r   r   N)Úlen)Úrs© r
   ú]/var/www/html/myproject/venv/lib/python3.10/site-packages/kombu/asynchronous/aws/sqs/queue.pyÚ
list_first   s   r   c                   @   s  e Zd ZdZddefdd„Zdd„ Ze Z Z Z	 Z
 Z Z Z Z Z ZZd0dd	„Zd1d
d„Zd2dd„Zdd„ Zd1dd„Zdd„ Z	d1dd„Zd1dd„Z		d3dd„Zd4dd„Zd1dd„Zdd „ Z		d5d"d#„Zd1d$d%„Zd1d&d'„Z d1d(d)„Z!d1d*d+„Z"		-d6d.d/„Z#dS )7r   zAsync SQS Queue.Nc                 C   s   || _ || _|| _d | _d S ©N)Ú
connectionÚurlÚmessage_classÚvisibility_timeout)Úselfr   r   r   r
   r
   r   Ú__init__   s   
zAsyncQueue.__init__c                 O   s   t ƒ ‚r   )ÚNotImplementedError)r   ÚargsÚkwargsr
   r
   r   Ú_NA   s   zAsyncQueue._NAÚAllc                 C   ó   | j  | ||¡S r   )r   Úget_queue_attributes)r   Ú
attributesÚcallbackr
   r
   r   Úget_attributes    s   ÿzAsyncQueue.get_attributesc                 C   s   | j  | |||¡S r   )r   Úset_queue_attribute)r   Ú	attributeÚvaluer   r
   r
   r   Úset_attribute%   s   ÿzAsyncQueue.set_attributeÚVisibilityTimeoutc                 C   s   |   |t| j||tƒ¡S r   ©r   r   Ú_coerce_field_valueÚint)r   r   Ú_attrr
   r
   r   Úget_timeout*   s
   
ÿÿzAsyncQueue.get_timeoutc                 C   s   ||| ƒS r   r
   )r   ÚkeyÚtypeÚresponser
   r
   r   r$   1   s   zAsyncQueue._coerce_field_valuec                 C   s   |   d|t| j|ƒ¡S ©Nr"   )r!   r   Ú_on_timeout_set)r   r   r   r
   r
   r   Úset_timeout4   s   ÿþzAsyncQueue.set_timeoutc                 C   s   |r|| _ | j S r   )r   )r   r   r
   r
   r   r,   <   s   zAsyncQueue._on_timeout_setc                 C   s   | j  | ||||¡S r   )r   Úadd_permission)r   ÚlabelÚaws_account_idÚaction_namer   r
   r
   r   r.   A   s   
ÿzAsyncQueue.add_permissionc                 C   r   r   )r   Úremove_permission)r   r/   r   r
   r
   r   r2   G   ó   zAsyncQueue.remove_permissionc                 C   s   | j d||tt|ƒd�S )Nr   )Úwait_time_secondsr   )Úget_messagesr   r   )r   r   r4   r   r
   r
   r   ÚreadJ   s
   ýzAsyncQueue.readc                 C   s"   | j j| | ¡ |t| j||ƒd�S ©N)r   )r   Úsend_messageÚget_body_encodedr   Ú_on_message_sent)r   ÚmessageÚdelay_secondsr   r
   r
   r   ÚwriteR   s   
þzAsyncQueue.writec                 C   ó   | j j| ||d�S r7   )r   Úsend_message_batch©r   Úmessagesr   r
   r
   r   Úwrite_batchX   ó   ÿzAsyncQueue.write_batchc                 C   s   |j |_ |j|_|S r   )ÚidÚmd5)r   Úorig_messageÚnew_messager
   r
   r   r:   ]   s   zAsyncQueue._on_message_sentr   c                 C   s   | j j| |||||d�S )N)Únumber_messagesr   r   r4   r   )r   Úreceive_message)r   Únum_messagesr   r   r4   r   r
   r
   r   r5   b   s   ûzAsyncQueue.get_messagesc                 C   r   r   )r   Údelete_message)r   r;   r   r
   r
   r   rK   l   r3   zAsyncQueue.delete_messagec                 C   r>   r7   )r   Údelete_message_batchr@   r
   r
   r   rL   o   rC   zAsyncQueue.delete_message_batchc                 C   r>   r7   )r   Úchange_message_visibility_batchr@   r
   r
   r   rM   t   rC   z*AsyncQueue.change_message_visibility_batchc                 C   s   | j j| |d�S r7   )r   Údelete_queue)r   r   r
   r
   r   Údeletey   r3   zAsyncQueue.deleteé
   ÚApproximateNumberOfMessagesc                 C   s   | j |t| j||tƒd�S r7   r#   )r   Ú	page_sizeÚvtimeoutr   r&   r
   r
   r   Úcount|   s
   
ÿÿzAsyncQueue.count)r   Nr   r+   )NNN)NN)r   NNNN)rP   rP   NrQ   )$Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Ú
count_slowÚdumpÚsave_to_fileÚsave_to_filenameÚsaveÚ
save_to_s3Úload_from_s3Úload_from_fileÚload_from_filenameÚloadÚclearr   r!   r'   r$   r-   r,   r.   r2   r6   r=   rB   r:   r5   rK   rL   rM   rO   rT   r
   r
   r
   r   r      sP    þÿÿÿÿ




ÿ

ÿ


ÿ




ÿN)rX   Ú
__future__r   r   Úviner   r;   r   Ú_all__r   r   r
   r
   r
   r   Ú<module>   s   