summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kafka/client.py3
-rw-r--r--kafka/conn.py2
-rw-r--r--kafka/consumer.py8
-rw-r--r--kafka/producer.py6
4 files changed, 18 insertions, 1 deletions
diff --git a/kafka/client.py b/kafka/client.py
index 1016051..550da08 100644
--- a/kafka/client.py
+++ b/kafka/client.py
@@ -158,6 +158,9 @@ class KafkaClient(object):
# Order the accumulated responses by the original key order
return (acc[k] for k in original_keys) if acc else ()
+ def __repr__(self):
+ return '<KafkaClient client_id=%s>' % (self.client_id)
+
def _raise_on_response_error(self, resp):
if resp.error == ErrorMapping.NO_ERROR:
return
diff --git a/kafka/conn.py b/kafka/conn.py
index a6d93f8..f353441 100644
--- a/kafka/conn.py
+++ b/kafka/conn.py
@@ -28,7 +28,7 @@ class KafkaConnection(local):
self._sock.settimeout(self.timeout)
self._dirty = False
- def __str__(self):
+ def __repr__(self):
return "<KafkaConnection host=%s port=%d>" % (self.host, self.port)
###################
diff --git a/kafka/consumer.py b/kafka/consumer.py
index 522d6ca..5be1bef 100644
--- a/kafka/consumer.py
+++ b/kafka/consumer.py
@@ -256,6 +256,10 @@ class SimpleConsumer(Consumer):
auto_commit_every_n=auto_commit_every_n,
auto_commit_every_t=auto_commit_every_t)
+ def __repr__(self):
+ return '<SimpleConsumer group=%s, topic=%s, partitions=%s>' % \
+ (self.group, self.topic, str(self.offsets.keys()))
+
def provide_partition_info(self):
"""
Indicates that partition info must be returned by the consumer
@@ -544,6 +548,10 @@ class MultiProcessConsumer(Consumer):
proc.start()
self.procs.append(proc)
+ def __repr__(self):
+ return '<MultiProcessConsumer group=%s, topic=%s, consumers=%d>' % \
+ (self.group, self.topic, len(self.procs))
+
def stop(self):
# Set exit and start off all waiting consumers
self.exit.set()
diff --git a/kafka/producer.py b/kafka/producer.py
index 6ed22ee..6b624f2 100644
--- a/kafka/producer.py
+++ b/kafka/producer.py
@@ -199,6 +199,9 @@ class SimpleProducer(Producer):
partition = self.next_partition.next()
return super(SimpleProducer, self).send_messages(partition, *msg)
+ def __repr__(self):
+ return '<SimpleProducer topic=%s, batch=%s>' % (self.topic, self.async)
+
class KeyedProducer(Producer):
"""
@@ -240,3 +243,6 @@ class KeyedProducer(Producer):
partitions = self.client.topic_partitions[self.topic]
partition = self.partitioner.partition(key, partitions)
return self.send_messages(partition, msg)
+
+ def __repr__(self):
+ return '<KeyedProducer topic=%s, batch=%s>' % (self.topic, self.async)