summaryrefslogtreecommitdiff
path: root/kafka/partitioner/base.py
diff options
context:
space:
mode:
authorbarrotsteindev <barrotstein@gmail.com>2016-09-28 20:30:32 +0300
committerDana Powers <dana.powers@gmail.com>2016-09-28 10:30:32 -0700
commitb8717b4b79462e83344f49bbd42312cf521d84aa (patch)
treec20e9a2f2e33e744702d277cb84e7a08c85d2218 /kafka/partitioner/base.py
parent5c784890b6f323ea37c6171a59184e9304cbcb5c (diff)
downloadkafka-python-b8717b4b79462e83344f49bbd42312cf521d84aa.tar.gz
Update Partitioners for use with KafkaProducer (#827)
Diffstat (limited to 'kafka/partitioner/base.py')
-rw-r--r--kafka/partitioner/base.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/kafka/partitioner/base.py b/kafka/partitioner/base.py
index 00f7be3..0e36253 100644
--- a/kafka/partitioner/base.py
+++ b/kafka/partitioner/base.py
@@ -5,22 +5,23 @@ class Partitioner(object):
"""
Base class for a partitioner
"""
- def __init__(self, partitions):
+ def __init__(self, partitions=None):
"""
Initialize the partitioner
Arguments:
- partitions: A list of available partitions (during startup)
+ partitions: A list of available partitions (during startup) OPTIONAL.
"""
self.partitions = partitions
- def partition(self, key, partitions=None):
+ def __call__(self, key, all_partitions=None, available_partitions=None):
"""
- Takes a string key and num_partitions as argument and returns
+ Takes a string key, num_partitions and available_partitions as argument and returns
a partition to be used for the message
Arguments:
- key: the key to use for partitioning
- partitions: (optional) a list of partitions.
+ key: the key to use for partitioning.
+ all_partitions: a list of the topic's partitions.
+ available_partitions: a list of the broker's currently avaliable partitions(optional).
"""
raise NotImplementedError('partition function has to be implemented')