kafka.net.transport

class kafka.net.transport.KafkaTCPTransport(net, sock, host=None)[source]
abort(error=None)[source]

Close the transport immediately.

Buffered data will be lost. No more data will be received. The protocol’s connection_lost() method will (eventually) be called with None as its argument.

abortConnection()[source]

Close the connection abruptly.

can_write_eof()[source]

Return True if this transport supports write_eof(), False if not.

close()[source]

Close the transport.

Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol’s connection_lost() method will (eventually) be called with None as its argument.

getHost()[source]

Similar to getPeer, but returns an address describing this side of the connection.

Returns IPv4Address or IPv6Address.

getPeer()[source]

Get the remote address of this connection.

Treat this method with caution. It is the unfortunate result of the CGI and Jabber standards, but should not be considered reliable for the usual host of reasons; port forwarding, proxying, firewalls, IP masquerading, etc.

Returns IPv4Address or IPv6Address.

getTcpKeepAlive()[source]

Return if SO_KEEPALIVE is enabled.

getTcpNoDelay()[source]

Return if TCP_NODELAY is enabled.

get_protocol()[source]

Return the current protocol.

get_write_buffer_limits()[source]

Get the high and low watermarks for write flow control. Return a tuple (low, high) where low and high are positive number of bytes.

get_write_buffer_size()[source]

Return the current size of the write buffer.

async handshake()[source]
host_port()[source]
is_closing()[source]

Return True if the transport is closing or closed.

is_reading()[source]

Return True if the transport is receiving.

property last_activity
loseConnection()[source]

Close my connection, after writing all pending data.

Note that if there is a registered producer on a transport it will not be closed until the producer has been unregistered.

loseWriteConnection()[source]

Half-close the write side of a TCP connection.

pause_reading()[source]

Pause the receiving end.

No data will be passed to the protocol’s data_received() method until resume_reading() is called.

resume_reading()[source]

Resume the receiving end.

Data received will once again be passed to the protocol’s data_received() method.

setTcpKeepAlive(enabled)[source]

Enable/disable SO_KEEPALIVE.

setTcpNoDelay(enabled)[source]

Enable/disable TCP_NODELAY.

set_protocol(protocol)[source]

Set a new protocol.

set_write_buffer_limits(high=None, low=None)[source]

Set the high- and low-water limits for write flow control.

These two values control when to call the protocol’s pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative.

The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently.

write(data)[source]

Write some data bytes to the transport.

This does not block; it buffers the data and arranges for it to be sent out asynchronously.

writeSequence(data)[source]

Write an iterable of byte strings to the physical connection.

If possible, make sure that all of the data is written to the socket at once, without first copying it all into a single byte string.

write_eof()[source]

Close the write end after flushing buffered data.

(This is like typing ^D into a UNIX program reading from stdin.)

Data may still be received.

writelines(list_of_data)[source]

Write a list (or any iterable) of data bytes to the transport.

class kafka.net.transport.KafkaSSLTransport(net, sock, ssl_context, host=None, ssl_check_hostname=False)[source]
async handshake()[source]