pykafka icon indicating copy to clipboard operation
pykafka copied to clipboard

Alias Broker._connection to Broker.connection?

Open dsuch opened this issue 6 years ago • 0 comments

Hello,

my PyKafka version is 2.8.0.

I am working on embedding PyKafka in Zato and I have a question about exposing the _connection attribute of Broker objects directly as connection.

The background is that all connection types in Zato have a certain lifecycle, part of which is the ability on the part of users to close them / shut down at any moment - this should clean up any resources and end all relevant TCP streams and each library does it a bit differently.

Usually, other libraries have public Python API for it, e.g. disconnect, close, shutdown or similar.

I read the source code of PyKafka and the closest that I could find was BrokerConnection.disconnect which closes TCP sockets, ignoring any potential errors; hence, what I do can be simplified to:

for broker in client.brokers.values(): # type: Broker
    broker._connection.disconnect()

I am a bit reluctant to use _connection though because it is marked as part of a private API - that is how I interpret the leading underscore.

Thus, I wonder if it could be either renamed or aliased to plain connection.

Alternatively, or in addition to it, I also see room for a PyKafka.disconnect/close method that could achieve the same.

But perhaps there are some implications I am not aware of and it is not that easy?

Thank you.

dsuch avatar Mar 16 '19 09:03 dsuch