summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMostafa-Elmenbawy <elmenabawym@gmail.com>2020-09-07 23:21:50 +0000
committerGitHub <noreply@github.com>2020-09-07 16:21:50 -0700
commitf6677cf616aace9b9d9ed2b764d3b52ace7d4230 (patch)
tree261fe6fbf99c62d58f9d020b897a29501af649d2
parenta27ab881726ed1a2d952867a1fa266573165d6aa (diff)
downloadkafka-python-f6677cf616aace9b9d9ed2b764d3b52ace7d4230.tar.gz
Add kafka.structs docstrings (#2080)
Co-authored-by: MostafaElmenabawy <momenabawy@synapse-analytics.io>
-rw-r--r--kafka/structs.py61
1 files changed, 58 insertions, 3 deletions
diff --git a/kafka/structs.py b/kafka/structs.py
index 9ab4f8b..0d225bc 100644
--- a/kafka/structs.py
+++ b/kafka/structs.py
@@ -1,27 +1,82 @@
+""" Other useful structs """
from __future__ import absolute_import
from collections import namedtuple
-# Other useful structs
+"""A topic and partition tuple
+
+Keyword Arguments:
+ topic (str): A topic name
+ partition (int): A partition id
+"""
TopicPartition = namedtuple("TopicPartition",
["topic", "partition"])
+
+"""A Kafka broker metadata used by admin tools.
+
+Keyword Arguments:
+ nodeID (int): The Kafka broker id.
+ host (str): The Kafka broker hostname.
+ port (int): The Kafka broker port.
+ rack (str): The rack of the broker, which is used to in rack aware
+ partition assignment for fault tolerance.
+ Examples: `RACK1`, `us-east-1d`. Default: None
+"""
BrokerMetadata = namedtuple("BrokerMetadata",
["nodeId", "host", "port", "rack"])
+
+"""A topic partition metadata describing the state in the MetadataResponse.
+
+Keyword Arguments:
+ topic (str): The topic name of the partition this metadata relates to.
+ partition (int): The id of the partition this metadata relates to.
+ leader (int): The id of the broker that is the leader for the partition.
+ replicas (List[int]): The ids of all brokers that contain replicas of the
+ partition.
+ isr (List[int]): The ids of all brokers that contain in-sync replicas of
+ the partition.
+ error (KafkaError): A KafkaError object associated with the request for
+ this partition metadata.
+"""
PartitionMetadata = namedtuple("PartitionMetadata",
["topic", "partition", "leader", "replicas", "isr", "error"])
+
+"""The Kafka offset commit API
+
+The Kafka offset commit API allows users to provide additional metadata
+(in the form of a string) when an offset is committed. This can be useful
+(for example) to store information about which node made the commit,
+what time the commit was made, etc.
+
+Keyword Arguments:
+ offset (int): The offset to be committed
+ metadata (str): Non-null metadata
+"""
OffsetAndMetadata = namedtuple("OffsetAndMetadata",
# TODO add leaderEpoch: OffsetAndMetadata(offset, leaderEpoch, metadata)
["offset", "metadata"])
+
+"""An offset and timestamp tuple
+
+Keyword Arguments:
+ offset (int): An offset
+ timestamp (int): The timestamp associated to the offset
+"""
OffsetAndTimestamp = namedtuple("OffsetAndTimestamp",
["offset", "timestamp"])
-# Define retry policy for async producer
-# Limit value: int >= 0, 0 means no retries
+"""Define retry policy for async producer
+
+Keyword Arguments:
+ Limit (int): Number of retries. limit >= 0, 0 means no retries
+ backoff_ms (int): Milliseconds to backoff.
+ retry_on_timeouts:
+"""
RetryOptions = namedtuple("RetryOptions",
["limit", "backoff_ms", "retry_on_timeouts"])