
    /hk                       d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	m
Z
m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mZ ddlmZ ddlmZ ddlmZ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) ddl'm*Z+ ddl,m*Z- ddl.m*Z/ ddl0m1Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8m9Z9 ddl:m;Z;m<Z< ddl=m>Z> ddl?m@Z@  e6d          ZA eBejC                  h dz
  ZD eEd           eEd          id eDD             ZF G d  d!          ZG G d" d#          ZHejI         G d$ d%                      ZJ G d& d'e@jK                  ZK G d( d)e@jL                  ZLdS )*ap  GCP Pub/Sub transport module for kombu.

More information about GCP Pub/Sub:
https://cloud.google.com/pubsub

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

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

Connection string has the following formats:

.. code-block::

    gcpubsub://projects/project-name

Transport Options
=================
* ``queue_name_prefix``: (str) Prefix for queue names.
* ``ack_deadline_seconds``: (int) The maximum time after receiving a message
  and acknowledging it before pub/sub redelivers the message.
* ``expiration_seconds``: (int) Subscriptions without any subscriber
  activity or changes made to their properties are removed after this period.
  Examples of subscriber activities include open connections,
  active pulls, or successful pushes.
* ``wait_time_seconds``: (int) The maximum time to wait for new messages.
  Defaults to 10.
* ``retry_timeout_seconds``: (int) The maximum time to wait before retrying.
* ``bulk_max_messages``: (int) The maximum number of messages to pull in bulk.
  Defaults to 32.
    )annotationsN)FIRST_COMPLETEDFutureThreadPoolExecutorwait)suppress)getpid)Empty)Lock)	monotonicsleep)NAMESPACE_OIDuuid3)gethostnametimeout)AlreadyExistsDeadlineExceededPermissionDenied)Retry)monitoring_v3)query)PublisherClientSubscriberClient)
exceptions)gapic_version)TRANSIENT_DELIVERY_MODE)
get_logger)bytes_to_strsafe_str)dumpsloads)cached_property   )virtualzkombu.transport.gcpubsub>   _-.r(   r'   c                H    i | ]}t          |          t          d            S )r&   )ord).0cs     \/var/www/html/e360mart/e360mart_env/lib/python3.11/site-packages/kombu/transport/gcpubsub.py
<dictcomp>r.   S   s&    999As1vvs3xx999    c                  @    e Zd ZdZd Zd ZddZddZd	 Zd
 Z	d Z
dS )
UnackedIdszThreadsafe list of ack_ids.c                :    g | _         t                      | _        d S N)_listr   _lockselfs    r-   __init__zUnackedIds.__init__Z   s    
VV


r/   c                :    | j                             |           d S r3   )r4   appendr7   vals     r-   r:   zUnackedIds.append^   s    
#r/   valslistc                :    | j                             |           d S r3   )r4   extend)r7   r=   s     r-   r@   zUnackedIds.extendb   s    
$r/   c                x    | j         5  | j                            |          cd d d            S # 1 swxY w Y   d S r3   )r5   r4   pop)r7   indexs     r-   rC   zUnackedIds.popf   s    Z 	) 	):>>%((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   /33c                    | j         5  t          t                    5  | j                            |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S r3   )r5   r   
ValueErrorr4   remover;   s     r-   rG   zUnackedIds.removej   s    Z 	# 	#*-- 	# 	#Jc"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s3   AAAA	AA	AA #A c                l    | j         5  t          | j                  cd d d            S # 1 swxY w Y   d S r3   )r5   lenr4   r6   s    r-   __len__zUnackedIds.__len__n   sy    Z 	# 	#tz??	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#s   )--c                    | j         |         S r3   )r4   )r7   items     r-   __getitem__zUnackedIds.__getitem__r   s    z$r/   N)r=   r>   )rA   )__name__
__module____qualname____doc__r8   r:   r@   rC   rG   rJ   rM    r/   r-   r1   r1   W   s        %%           ) ) ) )# # ## # #         r/   r1   c                  0    e Zd ZdZd	dZd
dZd
dZd ZdS )AtomicCounterzIThreadsafe counter.

    Returns the value after inc/dec operations.
    r   c                :    || _         t                      | _        d S r3   )_valuer   r5   )r7   initials     r-   r8   zAtomicCounter.__init__}   s    VV


r/   r$   c                r    | j         5  | xj        |z  c_        | j        cd d d            S # 1 swxY w Y   d S r3   r5   rV   r7   ns     r-   inczAtomicCounter.inc       Z 	 	KK1KK;	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   ,00c                r    | j         5  | xj        |z  c_        | j        cd d d            S # 1 swxY w Y   d S r3   rY   rZ   s     r-   deczAtomicCounter.dec   r]   r^   c                R    | j         5  | j        cd d d            S # 1 swxY w Y   d S r3   rY   r6   s    r-   getzAtomicCounter.get   ss    Z 	 	;	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s     N)r   )r$   )rN   rO   rP   rQ   r8   r\   r`   rb   rR   r/   r-   rT   rT   w   si         
      
   
    r/   rT   c                  h    e Zd ZU dZded<   ded<   ded<   ded<    ej        e          Zded	<   d
S )QueueDescriptorzPub/Sub queue descriptor.strname
topic_pathsubscription_idsubscription_path)default_factoryr1   unacked_idsN)	rN   rO   rP   rQ   __annotations__dataclassesfieldr1   rk   rR   r/   r-   rd   rd      sc         ##IIIOOO/k/
KKKKKKKKKKr/   rd   c                      e Zd ZU dZdZdZdZdZdZdZ	dZ
dZ e            Zd	Zd
ed<    ej                    Z e            Zi Zded<    e            Zded<    fdZefdCdZd Z	 dDdEdZdFdZ	 	 	 	 	 	 dGdHd Zd! Zd" Zd# Z dDdId'Z!dJd*Z"dId+Z#dKd,Z$dD fd-	Z%dLd.Z&dM fd/	Z'dNd2Z(dOd3Z)d4 Z*dOd5Z+e,d6             Z-e,d7             Z.e,d8             Z/e0d9             Z1e0d:             Z2e,d;             Z3e,d<             Z4e,d=             Z5e,d>             Z6e,d?             Z7e,d@             Z8 fdAZ9e:dB             Z; xZ<S )PChannelzGCP Pub/Sub channel.TF
      iQ i,      Nzthreading.Thread_unacked_extenderzdict[str, QueueDescriptor]_queue_cachezset[str]_tmp_subscriptionsc                    t                      j        |i | t                      | _        t                              d| j        j                   t          	                    | j        j                  | _
        | j                                        dk    r^t          j        | j        d          t           _        | j                                         t           j                                         d S d S )Nznew GCP pub/sub channel: %sr$   T)targetdaemon)superr8   r   poolloggerinfoconninfohostname	Transport	parse_uri
project_id_n_channelsr\   	threadingThread_extend_unacked_deadlinerp   rt   _stop_extenderclearstart)r7   argskwargs	__class__s      r-   r8   zChannel.__init__   s    $)&)))&((	14=3IJJJ#--dm.DEE!!Q&&(1(84) ) )G% %%'''%++----- '&r/   rf   re   returnc                    |                     | j                  s
| j        |z   }t          t          |                                        |          S )z7Format AMQP queue name into a valid Pub/Sub queue name.)
startswithqueue_name_prefixre   r    	translate)r7   rf   tables      r-   entity_namezChannel.entity_name   sH    t566 	1)D0D8D>>"",,U333r/   c                   |                      |          j        }|                     |          }t                              d||||           i }|dk    r0dd| di}| j                            | j        |          }| j        }n|dk    rt          t          t                       dt                                  }	| d|	 }
| j                            | j        |
          }| j                            |           | j                            |           d	}nt!          d
| d          |                     | j        ||          }|                     ||||           t'          ||||          }|| j        |<   d S )Nz9binding queue: %s to %s exchange: %s with routing_key: %sdirectfilterzattributes.routing_key=""fanoutr(   r'   iX  zexchange type z not implemented)rg   ri   filter_argsmsg_retention)rf   rg   rh   ri   )typeoftyper   r|   debug
subscriberri   r   expiration_secondsr   r   r   r	   rv   add_fanout_exchangesNotImplementedError_create_topic_create_subscriptionrd   ru   )r7   exchangerouting_keypatternqueueexchange_typer   ri   message_retention_durationuiduniq_sub_nameexchange_topicqdescs                r-   _queue_bindzChannel._queue_bind   s   H--2  ''G	
 	
 	
 H$$ C[CCCK !% A A! ! *.)@&&h&& =[]]*G*GVXX*G*GHHJC$,,s,,M $ A A! ! #''(9:::"&&x000),&&%@@@@   ++OX'A
 
 	!!%/#4	 	" 	
 	
 	
  %!/	
 
 
 $)%   r/   r   topic_idr   intc                L   | j                             ||          }|                     |          rt                              d|           |S 	 t                              d|           d|i}|r| d|d<   | j                             |           n# t          $ r Y nw xY w|S )Nztopic: %s existszcreating topic: %srf   sr   request)	publisherrg   _is_topic_existsr|   r   create_topicr   )r7   r   r   r   rg   r   s         r-   r   zChannel._create_topic  s     ^..z8DD
  ,, 	LL+Z888		LL-z:::z*G) 5 2444 0 N'''8888 	 	 	D	 s   AB 
B! B!rg   boolc                v    | j                             dd| j         i          }|D ]}|j        |k    r dS dS )Nprojectz	projects/r   TF)r   list_topicsr   rf   )r7   rg   topicsts       r-   r   zChannel._is_topic_exists  s`    ++ =DO = => , 
 
  	 	Av##tt $ur/   ri   r   c                b   |p| j                             | j        |          }|p| j                            ||          }	 t
                              d|||           |p| j        }| j                             ||| j	        d| j         di| dd|pi            n# t          $ r Y nw xY w|S )Nz0creating subscription: %s, topic: %s, filter: %sttlr   )rf   topicack_deadline_secondsexpiration_policyr   r   )r   ri   r   r   rg   r|   r   r   create_subscriptionr   r   )r7   r   r   rg   ri   r   r   s          r-   r   zChannel._create_subscription#  s     L00(KK 	   
4>#<#<$
 $

	LLB!	   *DT-DMO//-',0,E$"9<<<* 6C2E2E2E	 	 #(b	 0      	 	 	D	  s   AB 
B,+B,c                   |                      |          }t                              d|           | j                            |          }|sdS | j                            d|j        i           | j                            |d           dS )zDelete a queue by name.zdeleting queue: %sNsubscriptionr   )	r   r|   r}   ru   rb   r   delete_subscriptionri   rC   )r7   r   r   r   r   s        r-   _deletezChannel._deleteK  s      ''(%000!%%e,, 	F++#U%<= 	, 	
 	
 	
 	eT*****r/   c                @   |                      |          }| j        |         }|                     |          }t                              d||j        |           t          |          }| j                            |j        |	                    d          |           dS )zPut a message onto the queue.z8putting message to queue: %s, topic: %s, routing_key: %sutf-8)r   N)
r   ru   _get_routing_keyr|   r   rg   r!   r   publishencode)r7   r   messager   r   r   encoded_messages          r-   _putzChannel._putW  s      ''!%(++G44F		
 	
 	
  ..""7++# 	 	
 	
 	
 	
 	
r/   c                N   |                      ||           | j                            | j        |          }t                              d||           t          |          }| j                            ||                    d          t          | j
                             dS )z#Put a message onto fanout exchange.z-putting msg to fanout exchange: %s, topic: %sr   deadline)retryN)_lookupr   rg   r   r|   r   r!   r   r   r   retry_timeout_seconds)r7   r   r   r   r   rg   r   s          r-   _put_fanoutzChannel._put_fanouti  s    X{+++^..tII
;	
 	
 	

  ..""7++!;<<< 	 	
 	
 	
 	
 	
r/   r   r   floatc                   |                      |          }| j        |         }	 | j                            |j        ddt          | j                  |p| j                  }n# t          $ r t                      w xY wt          |j                  dk    rt                      |j        d         }|j        }t          |j        j                  }|d         d         }t                               d|||d                    |                     |d                   r8t                               d	|           |                     |g|j                   n3|||j        j        |j        d
|d<   |j                            |           |S )z(Retrieves a single message from a queue.r$   r   max_messagesr   r   r   r   r   
propertiesdelivery_infoz-queue:%s got message, ack_id: %s, payload: %szauto acking message ack_id: %sr   ack_id
message_idri   gcpubsub_message)r   ru   r   pullri   r   r   wait_time_secondsr   r
   rI   received_messagesr   r"   r   datar|   r   _is_auto_ack_do_ackr   rk   r:   )	r7   r   r   r   responser   r   payloadr   s	            r-   _getzChannel._gety  s     ''!%(
	++$)$;$%  T%?@@@94#9 ,  HH   	 	 	''M	 x)**a//''M,Q/,---o>;L!		
 	
 	
 W\233 
	-LL96BBBLL&5#:;;;;  %o8%*%<	1 1M,- $$V,,,s   ?A$ $A=payload_propertiesdictc                V    |d         d         }|d         }|t           k    p|| j        v S )Nr   r   delivery_mode)r   r   )r7   r   r   r   s       r-   r   zChannel._is_auto_ack  s9    %o6zB*?;44 2411	
r/   c                   |                      |          }| j        |         }|                                 }|st                      	 | j                            |j        |dt          | j                  |p| j	                  }n# t          $ r t                      w xY w|j        }t          |          dk    rt                      g }g }	t                              dt          |          |           |D ]}
|
j        }t!          t#          |
j        j                            }|d         d         }|||
j        j        |j        d|d	<   |                     |d                   r|                    |           n|j                            |           |	                    |           |r6t                              d
|           |                     ||j                   ||	fS )z(Retrieves bulk of messages from a queue.r   r   r   r   z#batching %d messages from queue: %sr   r   r   r   zauto acking ack_ids: %s)r   ru   _get_max_messages_estimater
   r   r   ri   r   r   r   r   r   rI   r|   r   r   r"   r   r   r   r   r   r:   rk   r   )r7   r   r   prefixed_queuer   r   r   r   auto_ack_idsret_payloadsr   r   r   r   s                 r-   	_get_bulkzChannel._get_bulk  s!   ))%00!.16688 	''M
	++$)$;$0  T%?@@@94#9 ,  HH   	 	 	''M	 %6 !!Q&&''M1!""	
 	
 	

 ) 	) 	)G^FL)=>>??G#L1/BM' %o8%*%<	1 1M,-   !677 1##F++++!((000(((( 	@LL2LAAALLu'>???l""s   ?B B!c                N    | j                                         }| j        }||n|S r3   )qoscan_consume_max_estimatebulk_max_messages)r7   max_allowedmax_if_unlimiteds      r-   r   z"Channel._get_max_messages_estimate  s/    h77991#.#6KGr/   c                |   | j         j                            |i           }|s#t                                          |||          S |                     |                              |                     |          |||          }|r|S t          	                    d|           | 
                    |||           |gS )Nz3no queues bound to exchange: %s, binding on the fly)state	exchangesrb   rz   r   r   lookup	get_tabler|   r   
queue_bind)r7   r   r   defaultexchange_inforetr   s         r-   r   zChannel._lookup  s    
,002>> 	C77??8['BBBkk(##**NN8$$	
 
  	JA	
 	
 	
 	(K888zr/   c                   |                      |          }|| j        vrdS | j        |         }t          j        | j        | j        dt          j                                        d                              |j	                  }t          t                    5  t          d |D                       cddd           S # 1 swxY w Y   dS )	zReturn the number of messages in a queue.

        This is a *rough* estimation, as Pub/Sub doesn't provide
        an exact API.
        r   z;pubsub.googleapis.com/subscription/num_undelivered_messagesr$   )end_timeminutes)rh   c              3  D   K   | ]}|j         d          j        j        V  dS )r   N)pointsvalueint64_value)r+   contents     r-   	<genexpr>z Channel._size.<locals>.<genexpr>  s@        8?q!'3     r/   NrA   )r   ru   r   Querymonitorr   datetimenowselect_resourcesrh   r   r   sum)r7   r   r   results       r-   _sizezChannel._size  s#      '')))1!%(LOI&**,,
 
 
 
5+@

A
A 	 &'' 	 	  CI    	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 rs   C  CCc                   |rt          d          | j                            |          j        }|d         }|d         }|d         }t                              d||           |d         }|                     |g|           | j        |         }|j        	                    |           t                                          |           dS )zAcknowledge one message.zmultiple acks not implementedr   r   r   z!ack message. queue: %s ack_id: %sri   N)r   r   rb   r   r|   r   r   ru   rk   rG   rz   	basic_ack)
r7   delivery_tagmultipler   pubsub_messager   r   ri   r   r   s
            r-   r  zChannel.basic_ack  s     	G%&EFFF\22@&'9:)w'8%HHH*+>?fX0111!%(  (((,'''''r/   ack_ids	list[str]c                j    | j                             ||dt          | j                             d S )N)r   r  r   )r   r   )r   acknowledger   r   )r7   r  ri   s      r-   r   zChannel._do_ack#  sG    ##%67KK!;<<< 	$ 	
 	
 	
 	
 	
r/   c                   |                      |          }| j                            |          }|sdS |                     |          }| j                            |j        t          j                                        d           |S )z'Delete all current messages in a queue.N)r   timer   )	r   ru   rb   r  r   seekri   r  r  )r7   r   r   r[   s       r-   _purgezChannel._purge)  s      ''!%%e,, 	FJJu % 7 )--//  	 	
 	
 	
 r/   c           
        t          j                    }t                              d|           | j        dz  }t          || j        dz            }| j                            |          s| j	        
                                D ]}t          |j                  dk    r"t                              d||j                   <t                              d||j        t          |j                  t          |j                             | j                            |j        t          |j                  | j        d           | j                            |          t                              d	|           d S )
Nz/unacked deadline extension thread: [%s] started      r   z'thread [%s]: no unacked messages for %sz5thread [%s]: extend ack deadline for %s: %d msgs [%s])r   r  r   r   z.unacked deadline extension thread [%s] stopped)r   get_native_idr|   r}   _min_ack_deadlinemaxr   r   r   ru   valuesrI   rk   r   ri   r>   r   modify_ack_deadline)r7   	thread_idmin_deadline_sleep
sleep_timer   s        r-   r   z Channel._extend_unacked_deadline9  s   +--	=	
 	
 	
 "3a7+T-F-JKK
%**:66 	*1133  u())Q..LLA!/  
 K+)***++   33(-(?#'(9#:#:040I  4    ! %**:66 	. 	<i	
 	
 	
 	
 	
r/   c                    |                      |          }| j                            | j        |          }t                              d||           | j                            |           d S )Nz0after_reply_message_received: queue: %s, sub: %s)r   r   ri   r   r|   r   rv   r   )r7   r   subs      r-   after_reply_message_receivedz$Channel.after_reply_message_received\  sj      ''o//GG>s	
 	
 	
 	##C(((((r/   c                    t                      S r3   )r   r6   s    r-   r   zChannel.subscriberd  s    !!!r/   c                    t                      S r3   )r   r6   s    r-   r   zChannel.publisherh  s       r/   c                (    t          j                    S r3   )r   MetricServiceClientr6   s    r-   r  zChannel.monitorl  s    0222r/   c                    | j         j        S r3   )
connectionclientr6   s    r-   r~   zChannel.conninfop  s    %%r/   c                $    | j         j        j        S r3   )r6  r7  transport_optionsr6   s    r-   r9  zChannel.transport_optionst  s    %77r/   c                B    | j                             d| j                  S )Nr   )r9  rb   default_wait_time_secondsr6   s    r-   r   zChannel.wait_time_secondsx  %    %))!?
 
 	
r/   c                B    | j                             d| j                  S )Nr   )r9  rb   default_retry_timeout_secondsr6   s    r-   r   zChannel.retry_timeout_seconds~  s%    %))#T%G
 
 	
r/   c                B    | j                             d| j                  S )Nr   )r9  rb   default_ack_deadline_secondsr6   s    r-   r   zChannel.ack_deadline_seconds  s%    %))"D$E
 
 	
r/   c                8    | j                             dd          S )Nr   zkombu-)r9  rb   r6   s    r-   r   zChannel.queue_name_prefix  s    %))*=xHHHr/   c                B    | j                             d| j                  S )Nr   )r9  rb   default_expiration_secondsr6   s    r-   r   zChannel.expiration_seconds  s%    %)) $"A
 
 	
r/   c                B    | j                             d| j                  S )Nr   )r9  rb   default_bulk_max_messagesr6   s    r-   r   zChannel.bulk_max_messages  r<  r/   c                2   t                               d           | j        r| j                                        }t	          t
                    5  t                               d|           | j                            d|i           ddd           n# 1 swxY w Y   | j        | j        	                                s7| j
                                         t          j                                         t                                                       dS )zClose the channel.zclosing channelzdeleting subscription: %sr   r   N)r|   r   rv   rC   r   	Exceptionr   r   r   r`   r   setrp   rt   joinrz   close)r7   r/  r   s     r-   rJ  zChannel.close  s9   &'''% 	)--//C)$$  8#>>>33+S1 4                  % 	 ##%% 	-##%%%%**,,,s   9BBBc                f    | d                              di                                dd          }|S )Nr   r   r    )rb   )r   r   s     r-   r   zChannel._get_routing_key  s7     L!S"%%S## 	
 r/   )rf   re   r   re   r3   )r   re   r   re   r   r   r   re   )rg   re   r   r   )NNNNNN)r   re   r   re   rg   re   ri   re   r   r   r   re   )r   re   r   r   )r   r   )r   r   )r   re   r   r   )F)r  r  ri   re   )r   re   )=rN   rO   rP   rQ   supports_fanout
do_restorer;  r@  rC  r>  rE  r'  rH  r   rt   rl   r   Eventr   rT   r   ru   rv   r8   CHARS_REPLACE_TABLEr   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r"  r   r0  r#   r   r   r  propertyr~   r9  r   r   r   r   r   r   rJ  staticmethodr   __classcell__r   s   @r-   rp   rp      s        OJ "#& !&$'! "*.....$Y_&&N-//K/1L1111#&355((((. . . . . ,? 4 4 4 4 4=) =) =)F +/	    0    !%!&! &! &! &! &!P
+ 
+ 
+
 
 
$
 
 
 ) ) ) ) )V
 
 
 
1# 1# 1# 1#fH H H H
     &   8( ( ( ( ( ( 
 
 
 
    !
 !
 !
F) ) ) ) " " _" ! ! _! 3 3 _3 & & X& 8 8 X8 
 
 _

 
 
 _

 
 
 _

 I I _I 
 
 _

 
 
 _

       \    r/   rp   c                  t    e Zd ZdZeZdZdZej        j	        e
j        fz   Z	ej        j        ej        ej        ej        ej        ej        fz   ej        fz   ZdZdZej        j                             eddg                    Z fd	Zd
 Zedd            Zeddd            ZddZd Z d Z!d Z" xZ#S )r   zGCP Pub/Sub transport.Tg?gcpubsub	pubsub_v1r   r   )r   c                     t                      j        |fi | t                      | _        t	                      | _        d S r3   )rz   r8   r   _poolr   _get_bulk_future_to_queue)r7   r7  r   r   s      r-   r8   zTransport.__init__  sA    **6***'))
<@FF&&&r/   c                    t           j        S r3   )package_version__version__r6   s    r-   driver_versionzTransport.driver_version  s    **r/   urire   r   c                b    |                      d          d         }|                    d          S )Nzgcpubsub://projects/r$   /)splitstrip)r_  r   s     r-   r   zTransport.parse_uri  s-    
 ))233A6}}S!!!r/   F**c                
    |pdS )Nzgcpubsub://rR   )r7   r_  include_passwordmasks       r-   as_urizTransport.as_uri  s    #m#r/   Nc                   t                      }| j        }|r
|r||k    r|}	 	 |                     |           d S # t          $ r9 |r#t                      |z
  |k    rt	                      |rt          |           Y nw xY w`)Nr$   r   )r   polling_interval_drain_from_active_queuesr
   socket_timeoutr   )r7   r6  r   
time_startrj  s        r-   drain_eventszTransport.drain_events  s    [[
0 	'' 	',<w,F,F&		..w.???   , , , +y{{Z77BB(***# ,*+++	,		s   < A A?>A?c                   |                                   |                     d           t          | j        |t                    \  }}d |D             }||z  }|D ]}| j                            |d            |st                      t                              dt          |                     |D ]}|
                                \  }}|D ]X}t                              d|           || j        vrt                              d|           B|                     ||           Y| j                            |d            d S )Nrq   r   )r   return_whenc                :    h | ]}|                                 |S rR   )	exceptionr+   fs     r-   	<setcomp>z6Transport._drain_from_active_queues.<locals>.<setcomp>  s%    222qAKKMM2222r/   zgot %d done get_bulk tasksz consuming message from queue: %sz&Message for queue %s without consumers)_rm_empty_bulk_requests_submit_get_bulk_requestsr   rZ  r   rC   r
   r|   r   rI   r  
_callbackswarning_deliver)	r7   r   doner&   emptyrt  r   payloadsr   s	            r-   rk  z#Transport._drain_from_active_queues  st   $$&&&
 	&&r&222*'
 
 
a
 32D222 	8 	8A*..q$7777 	''M13t99=== 
	8 
	8AhhjjOE8# . .?GGG//NN@%   gu----*..q$7777
	8 
	8r/   c                h    d | j         D             }|D ]}| j                             |d            d S )Nc                b    h | ],}|                                 |                                *|-S rR   )r{  rr  rs  s     r-   ru  z4Transport._rm_empty_bulk_requests.<locals>.<setcomp>  sH     
 
 
vvxx
 KKMM

 
 
r/   )rZ  rC   )r7   r|  rt  s      r-   rv  z!Transport._rm_empty_bulk_requests  sZ    
 
3
 
 

  	8 	8A*..q$7777	8 	8r/   c                    t          | j                                                  }| j        D ]<}|j        D ]2}||v r| j                            |j        ||          }|| j        |<   3=d S r3   )rH  rZ  r)  channels_active_queuesrY  submitr   )r7   r   queues_with_submitted_get_bulkchannelr   futures         r-   rw  z#Transport._submit_get_bulk_requests   s    ),*1133*
 *
& } 	? 	?G / ? ?:::**7+<eWMM9>.v66	?	? 	?r/   )r_  re   r   re   )Frd  r3   )$rN   rO   rP   rQ   rp   can_parse_urlrj  r%   r   connection_errorspubsub_exceptionsTimeoutErrorchannel_errorspublisher_exceptionsFlowControlLimitErrorMessageTooLargeErrorPublishError#PublishToPausedOrderingKeyExceptionsubscriber_exceptionsAcknowledgeErrordriver_typedriver_name
implementsr@   	frozensetr8   r^  rR  r   classmethodrh  rn  rk  rv  rw  rS  rT  s   @r-   r   r     s         GM);&?  	( 6 5 - - D
	
 !1
3	4  KK"-44i8 455 5  JC C C C C
+ + + " " " \" $ $ $ $ [$    !8 !8 !8F8 8 8
? 
? 
? 
? 
? 
? 
?r/   r   )MrQ   
__future__r   rm   r  stringr   concurrent.futuresr   r   r   r   
contextlibr   osr	   r   r
   r   r   r   r   uuidr   r   _socketr   r   rl  google.api_core.exceptionsr   r   r   google.api_core.retryr   google.cloudr   google.cloud.monitoring_v3r   google.cloud.pubsub_v1r   r   r   r   google.cloud.pubsub_v1.publisherr  !google.cloud.pubsub_v1.subscriberr  google.pubsub_v1r   r\  kombu.entityr   	kombu.logr   kombu.utils.encodingr   r    kombu.utils.jsonr!   r"   kombu.utils.objectsr#   rL  r%   r|   rH  punctuationPUNCTUATIONS_TO_REPLACEr*   rP  r1   rT   	dataclassrd   rp   r   rR   r/   r-   <module>r     s  % %N # " " " " "          & & & & & & & & & & & &                         ! ! ! ! ! ! ! ! % % % % % % % %       - - - - - -: : : : : : : : : : ' ' ' ' ' ' & & & & & & , , , , , , D D D D D D D D B B B B B B O O O O O O( ( ( ( ( ( = = = = = = 0 0 0 0 0 0             7 7 7 7 7 7 7 7 ) ) ) ) ) ) ) ) / / / / / /      	.	/	/ #f011OOOC CHHcc#hh99!8999                @       2 L L L L L L L LU U U U Ugo U U Upw? w? w? w? w?! w? w? w? w? w?r/   