9?G d dl mZ d dlZd dlZd dlZd dlmZmZmZm Z d dl mZ d dlZd dl Z n# e$ r dZdZ Y nw xY wd dlmZ G d dej Z G d d e Z G d de ZdS ) )annotationsN)DictListOptionalUnion)ParseResult) ProtocolErrorc | e Zd Zej dd Zej dd Zej dd Zej dd Zej dd Z ej dd Z ej d Zej d Zej d Z ej d d Zej d ZdS )! Transporturir buffer_sizeintconnect_timeoutc K dS )z Connects to a server using the implemented transport. The uri passed is of type ParseResult that can be obtained calling urllib.parse.urlparse. N )selfr r r s r/builddir/build/BUILD/imunify360-venv-2.6.2/opt/imunify360/venv/lib/python3.11/site-packages/nats/aio/transport.pyconnectzTransport.connect Union[str, ParseResult]ssl_contextssl.SSLContextc K dS )a$ connect_tls is similar to connect except it tries to connect to a secure endpoint, using the provided ssl context. The uri can be provided as string in case the hostname differs from the uri hostname, in case it was provided as 'tls_hostname' on the options. Nr )r r r r r s r connect_tlszTransport.connect_tls s r payloadbytesc dS )zj Write bytes to underlying transport. Needs a call to drain() to be successfully written. Nr r r s r writezTransport.write+ r List[bytes]c dS )z Writes a list of bytes, one by one, to the underlying transport. Needs a call to drain() to be successfully written. Nr r s r writelineszTransport.writelines2 s r returnc K dS )z Reads a sequence of bytes from the underlying transport, up to buffer_size. The buffer_size is ignored in case the transport carries already frames entire messages (i.e. websocket). Nr r r s r readzTransport.read: r r c K dS )z\ Reads one whole frame of bytes (or message) from the underlying transport. Nr r s r readlinezTransport.readlineB r c K dS )zb Flushes the bytes queued for transmission when calling write() and writelines(). Nr r* s r drainzTransport.drainI r, r c K dS )zD Waits until the connection is successfully closed. Nr r* s r wait_closedzTransport.wait_closedP r, r c dS )z2 Closes the underlying transport. Nr r* s r closezTransport.closeW r! r boolc dS )z< Returns if underlying transport is at eof. Nr r* s r at_eofzTransport.at_eof^ r! r c dS )ze Returns if the transport was initialized, either by calling connect of connect_tls. Nr r* s r __bool__zTransport.__bool__e r! r Nr r r r r r r r r r r r r r )r r )r r" )r r r% r )r% r )r% r3 )__name__ __module____qualname__abcabstractmethodr r r r$ r( r+ r. r0 r2 r5 r7 r r r r r s r r c \ e Zd Zd ZddZdd Zd Zd ZddZd Z d Z d Zd Zd Z d ZdS )TcpTransportc > d | _ d | _ d | _ d | _ d S N)_bare_io_reader _io_reader_bare_io_writer _io_writerr* s r __init__zTcpTransport.__init__n s$ ?C:>?C:>r r r r r r c K t j t j |j |j | | d {V \ }}|x| _ | _ |x| _ | _ d S )N)hostportlimit) asynciowait_foropen_connectionhostnamerJ rC rD rE rF )r r r r rws r r zTcpTransport.connectt s %#\X! 1 232t122tr r r r r% Nonec K | j sJ t | j d t j }t j | }t j | j j ||t |t r|n|j }t j || d {V }t j |||t j } || c| _ | _ d S )N.connect must be called first)server_hostname)rF typer: rL StreamReaderStreamReaderProtocolget_running_loop start_tls transport isinstancestrrO rM StreamWriterrD ) r r r r r readerprotocoltransport_futurer[ writers r r zTcpTransport.connect_tls s UU4::#6 U U UUU %''/77"355??O%#-c3#7#7ICCS\ @ "*+;_MMMMMMMM %i67C[C]C]^^+16(r c 6 | j | S rB )rF r r s r r zTcpTransport.write s $$W---r c 6 | j | S rB )rF r$ r s r r$ zTcpTransport.writelines s ))'222r c K | j sJ t | j d | j | d {V S )NrT )rD rV r: r( r' s r r( zTcpTransport.read sU UU4::#6 U U UUU_))+666666666r c D K | j d {V S rB )rD r+ r* s r r+ zTcpTransport.readline s, _--/////////r c D K | j d {V S rB )rF r. r* s r r. zTcpTransport.drain s, _**,,,,,,,,,r c D K | j d {V S rB )rF r0 r* s r r0 zTcpTransport.wait_closed s, _00222222222r c 4 | j S rB )rF r2 r* s r r2 zTcpTransport.close s $$&&&r c 4 | j S rB )rD r5 r* s r r5 zTcpTransport.at_eof s %%'''r c R t | j ot | j S rB )r3 rF rD r* s r r7 zTcpTransport.__bool__ s! DO$$>do)>)>>r Nr8 ) r r r r r r r r r% rR r r )r: r; r<