
    j                        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 d dlmZ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  d dl!m"Z" de#fdZ$ G d dee      Z% G d dee      Z&y)    )Future)OptionalMappingUnion)uuid4)ClientOptions)Credentials)BatchSettings)make_publishermake_async_publisher)MultiplexedAsyncPublisherClient)MultiplexedPublisherClient)PublisherClientInterfaceAsyncPublisherClientInterface)ConstructableFromServiceAccount)PublisherClientId)RequireStarted)DEFAULT_BATCHING_SETTINGS)	TopicPathenable_idempotencec                 D    | rt        t               j                        S d S N)r   r   bytes)r   s    Glib/third_party/google/cloud/pubsublite/cloudpubsub/publisher_client.py_get_client_idr   0   s    /AUW]]+KtK    c                       e Zd ZU dZeed<   eed<   eZ	 ddddddde	e
   d	e	e   d
ede	e   def
dZ	 ddeeef   dededeeef   ddf
dZd Zd Zy)PublisherClientz
    A PublisherClient publishes messages similar to Google Pub/Sub.
    Any publish failures are unlikely to succeed if retried.

    Must be used in a `with` block or have __enter__() called before use.
    _impl_require_startedNgrpc_asyncioFper_partition_batching_settingscredentials	transportclient_optionsr   r#   r$   r%   r&   r   c                p    t        |      t        fd      | _        t               | _        y)ap  
        Create a new PublisherClient.

        Args:
            per_partition_batching_settings: The settings for publish batching. Apply on a per-partition basis.
            credentials: If provided, the credentials to use when connecting.
            transport: The transport to use. Must correspond to an asyncio transport.
            client_options: The client options to use when connecting. If used, must explicitly set `api_endpoint`.
            enable_idempotence: Whether idempotence is enabled, where the server will ensure that unique messages within a single publisher session are stored only once.
        c                 &    t        |       S N)topicr#   r$   r&   r%   	client_id)r   r*   r+   r&   r$   r#   r%   s    r   <lambda>z*PublisherClient.__init__.<locals>.<lambda>Y   s    .0O'-##r   N)r   r   r   r   r    selfr#   r$   r%   r&   r   r+   s    ```` @r   __init__zPublisherClient.__init__D   s.    & ##56	/	

 !/ 0r   r*   dataordering_keyattrsreturnzFuture[str]c                 v    | j                   j                           | j                  j                  d|||d|S N)r*   r1   r2    r    require_startedr   publishr/   r*   r1   r2   r3   s        r   r:   zPublisherClient.publishd   sC     	--/!tzz!! 
d
AF
 	
r   c                 n    | j                   j                          | j                  j                          | S r   )r    	__enter__r   r/   s    r   r=   zPublisherClient.__enter__p   s)    '')

r   c                 x    | j                   j                  |||       | j                  j                  |||       y r   )r   __exit__r    r/   exc_type	exc_value	tracebacks       r   r@   zPublisherClient.__exit__u   s0    

Hi;&&xIFr    )__name__
__module____qualname____doc__r   __annotations__r   WIRE_DEFAULT_BATCHINGr   r   r
   r	   strr   boolr0   r   r   r   r   r:   r=   r@   r7   r   r   r   r   4   s     $#$$ 5 DH-1'26#(1 *2-)@1 k*	1
 1 !/1 !1H 	

Y^$

 

 	


 c"

 



Gr   r   c                       e Zd ZU dZeed<   eed<   eZ	 ddddddde	e
   d	e	e   d
ede	e   def
dZ	 ddeeef   dededeeef   def
dZd Zd Zy)AsyncPublisherClienta  
    An AsyncPublisherClient publishes messages similar to Google Pub/Sub, but must be used in an
    async context. Any publish failures are unlikely to succeed if retried.

    Must be used in an `async with` block or have __aenter__() awaited before use.
    r   r    Nr!   Fr"   r#   r$   r%   r&   r   c                p    t        |      t        fd      | _        t               | _        y)au  
        Create a new AsyncPublisherClient.

        Args:
            per_partition_batching_settings: The settings for publish batching. Apply on a per-partition basis.
            credentials: If provided, the credentials to use when connecting.
            transport: The transport to use. Must correspond to an asyncio transport.
            client_options: The client options to use when connecting. If used, must explicitly set `api_endpoint`.
            enable_idempotence: Whether idempotence is enabled, where the server will ensure that unique messages within a single publisher session are stored only once.
        c                 &    t        |       S r)   )r   r,   s    r   r-   z/AsyncPublisherClient.__init__.<locals>.<lambda>   s    .0O'-##r   N)r   r   r   r   r    r.   s    ```` @r   r0   zAsyncPublisherClient.__init__   s.    & ##56	4	

 !/ 0r   r*   r1   r2   r3   r4   c                    K   | j                   j                           | j                  j                  d|||d| d {   S 7 wr6   r8   r;   s        r   r:   zAsyncPublisherClient.publish   sQ      	--/'TZZ'' 
d
AF
 
 	
 
s   >A AAc                    K   | j                   j                          | j                  j                          d {    | S 7 wr   )r    r=   r   
__aenter__r>   s    r   rU   zAsyncPublisherClient.__aenter__   s8     '')jj##%%% 	&s   8AAAc                    K   | j                   j                  |||       d {    | j                  j                  |||       y 7 "wr   )r   	__aexit__r    r@   rA   s       r   rW   zAsyncPublisherClient.__aexit__   s@     jj""8Y	BBB&&xIF 	Cs   !AA#ArE   )rG   rH   rI   rJ   r   rK   r   rL   r   r   r
   r	   rM   r   rN   r0   r   r   r   r   r:   rU   rW   r7   r   r   rP   rP   z   s     )($$ 5 DH-1'26#(1 *2-)@1 k*	1
 1 !/1 !1H 	

Y^$

 

 	


 c"

 



Gr   rP   N)'concurrent.futuresr   typingr   r   r   uuidr   google.api_core.client_optionsr   google.auth.credentialsr	   google.cloud.pubsub_v1.typesr
   ;google.cloud.pubsublite.cloudpubsub.internal.make_publisherr   r   Ogoogle.cloud.pubsublite.cloudpubsub.internal.multiplexed_async_publisher_clientr   Igoogle.cloud.pubsublite.cloudpubsub.internal.multiplexed_publisher_clientr   >google.cloud.pubsublite.cloudpubsub.publisher_client_interfacer   r   Cgoogle.cloud.pubsublite.internal.constructable_from_service_accountr   4google.cloud.pubsublite.internal.publisher_client_idr   0google.cloud.pubsublite.internal.require_startedr   4google.cloud.pubsublite.internal.wire.make_publisherr   rL   google.cloud.pubsublite.typesr   rN   r   r   rP   r7   r   r   <module>rg      s    & + +  8 / 6 S K 4Lt LCG.0O CGLEG!#BEGr   