pykafka.connection

class pykafka.connection.BrokerConnection(host, port, handler, buffer_size=1048576, source_host='', source_port=0)

Bases: object

BrokerConnection thinly wraps a socket.create_connection call and handles the sending and receiving of data that conform to the kafka binary protocol over that socket.

__del__()

Close this connection when the object is deleted.

__init__(host, port, handler, buffer_size=1048576, source_host='', source_port=0)

Initialize a socket connection to Kafka.

Parameters:
  • host (str) – The host to which to connect
  • port (int) – The port on the host to which to connect
  • handler (pykafka.handlers.Handler) – The pykafka.handlers.Handler instance to use when creating a connection
  • buffer_size (int) – The size (in bytes) of the buffer in which to hold response data.
  • source_host (str) – The host portion of the source address for the socket connection
  • source_port (int) – The port portion of the source address for the socket connection
__weakref__

list of weak references to the object (if defined)

connect(timeout)

Connect to the broker.

connected

Returns true if the socket connection is open.

disconnect()

Disconnect from the broker.

reconnect()

Disconnect from the broker, then reconnect

request(request)

Send a request over the socket connection

response()

Wait for a response from the broker