pykafka.partition

Author: Keith Bourgoin, Emmett Butler

class pykafka.partition.Partition(topic, id_, leader, replicas, isr)

Bases: object

A Partition is an abstraction over the kafka concept of a partition. A kafka partition is a logical division of the logs for a topic. Its messages are totally ordered.

__eq__(other)

x.__eq__(y) <==> x==y

__hash__() <==> hash(x)
__init__(topic, id_, leader, replicas, isr)

Instantiate a new Partition

Parameters:
  • topic (pykafka.topic.Topic) – The topic to which this Partition belongs
  • id (int) – The identifier for this partition
  • leader (pykafka.broker.Broker) – The broker that is currently acting as the leader for this partition.
  • replicas (Iterable of pykafka.broker.Broker) – A list of brokers containing this partition’s replicas
  • isr (Iterable of pykafka.broker.Broker) – The current set of in-sync replicas for this partition
__lt__(other)

x.__lt__(y) <==> x<y

__ne__(other)

x.__ne__(y) <==> x!=y

__repr__() <==> repr(x)
__weakref__

list of weak references to the object (if defined)

earliest_available_offset()

Get the earliest offset for this partition.

fetch_offset_limit(offsets_before, max_offsets=1)
Use the Offset API to find a limit of valid offsets
for this partition.
Parameters:
  • offsets_before (datetime.datetime or int) – Return an offset from before this timestamp (in milliseconds). Deprecated::2.7,3.6: do not use int
  • max_offsets (int) – The maximum number of offsets to return
id

The identifying int for this partition, unique within its topic

isr

The current list of in-sync replicas for this partition

latest_available_offset()

Get the offset of the next message that would be appended to this partition

leader

The broker currently acting as leader for this partition

replicas

The list of brokers currently holding replicas of this partition

topic

The topic to which this partition belongs

update(brokers, metadata)

Update this partition with fresh metadata.

Parameters:
  • brokers (List of pykafka.broker.Broker) – Brokers on which partitions exist
  • metadata (pykafka.protocol.PartitionMetadata) – Metadata for the partition