kafka.partitioner package

Submodules

kafka.partitioner.base module

class kafka.partitioner.base.Partitioner(partitions=None)[source]

Bases: object

Base class for a partitioner

kafka.partitioner.hashed module

kafka.partitioner.hashed.HashedPartitioner

alias of kafka.partitioner.hashed.LegacyPartitioner

class kafka.partitioner.hashed.LegacyPartitioner(partitions)[source]

Bases: object

DEPRECATED – See Issue 374

Implements a partitioner which selects the target partition based on the hash of the key

partition(key, partitions=None)[source]
class kafka.partitioner.hashed.Murmur2Partitioner(partitions=None)[source]

Bases: kafka.partitioner.base.Partitioner

Implements a partitioner which selects the target partition based on the hash of the key. Attempts to apply the same hashing function as mainline java client.

partition(key, partitions=None)[source]
kafka.partitioner.hashed.murmur2(data)[source]

Pure-python Murmur2 implementation.

Based on java client, see org.apache.kafka.common.utils.Utils.murmur2

Parameters:data (bytes) – opaque bytes

Returns: MurmurHash2 of data

kafka.partitioner.roundrobin module

class kafka.partitioner.roundrobin.CachedPartitionCycler(partitions=None)[source]

Bases: object

next()[source]
set_partitions(partitions)[source]
class kafka.partitioner.roundrobin.RoundRobinPartitioner(partitions=None)[source]

Bases: kafka.partitioner.base.Partitioner

partition(key, all_partitions=None, available_partitions=None)[source]

Module contents

class kafka.partitioner.DefaultPartitioner[source]

Bases: object

Default partitioner.

Hashes key to partition using murmur2 hashing (from java client) If key is None, selects partition randomly from available, or from all partitions if none are currently available

class kafka.partitioner.RoundRobinPartitioner(partitions=None)[source]

Bases: kafka.partitioner.base.Partitioner

partition(key, all_partitions=None, available_partitions=None)[source]
kafka.partitioner.HashedPartitioner

alias of kafka.partitioner.hashed.LegacyPartitioner

class kafka.partitioner.Murmur2Partitioner(partitions=None)[source]

Bases: kafka.partitioner.base.Partitioner

Implements a partitioner which selects the target partition based on the hash of the key. Attempts to apply the same hashing function as mainline java client.

partition(key, partitions=None)[source]
class kafka.partitioner.LegacyPartitioner(partitions)[source]

Bases: object

DEPRECATED – See Issue 374

Implements a partitioner which selects the target partition based on the hash of the key

partition(key, partitions=None)[source]