Skip to content

Commit 00beee1

Browse files
mmenbawyMostafaElmenabawy
authored and
Gabriel Tincu
committed
Add kafka.structs docstrings (dpkp#2080)
Co-authored-by: MostafaElmenabawy <[email protected]>
1 parent 5d30e41 commit 00beee1

File tree

1 file changed

+58
-3
lines changed

1 file changed

+58
-3
lines changed

kafka/structs.py

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,82 @@
1+
""" Other useful structs """
12
from __future__ import absolute_import
23

34
from collections import namedtuple
45

56

6-
# Other useful structs
7+
"""A topic and partition tuple
8+
9+
Keyword Arguments:
10+
topic (str): A topic name
11+
partition (int): A partition id
12+
"""
713
TopicPartition = namedtuple("TopicPartition",
814
["topic", "partition"])
915

16+
17+
"""A Kafka broker metadata used by admin tools.
18+
19+
Keyword Arguments:
20+
nodeID (int): The Kafka broker id.
21+
host (str): The Kafka broker hostname.
22+
port (int): The Kafka broker port.
23+
rack (str): The rack of the broker, which is used to in rack aware
24+
partition assignment for fault tolerance.
25+
Examples: `RACK1`, `us-east-1d`. Default: None
26+
"""
1027
BrokerMetadata = namedtuple("BrokerMetadata",
1128
["nodeId", "host", "port", "rack"])
1229

30+
31+
"""A topic partition metadata describing the state in the MetadataResponse.
32+
33+
Keyword Arguments:
34+
topic (str): The topic name of the partition this metadata relates to.
35+
partition (int): The id of the partition this metadata relates to.
36+
leader (int): The id of the broker that is the leader for the partition.
37+
replicas (List[int]): The ids of all brokers that contain replicas of the
38+
partition.
39+
isr (List[int]): The ids of all brokers that contain in-sync replicas of
40+
the partition.
41+
error (KafkaError): A KafkaError object associated with the request for
42+
this partition metadata.
43+
"""
1344
PartitionMetadata = namedtuple("PartitionMetadata",
1445
["topic", "partition", "leader", "replicas", "isr", "error"])
1546

47+
48+
"""The Kafka offset commit API
49+
50+
The Kafka offset commit API allows users to provide additional metadata
51+
(in the form of a string) when an offset is committed. This can be useful
52+
(for example) to store information about which node made the commit,
53+
what time the commit was made, etc.
54+
55+
Keyword Arguments:
56+
offset (int): The offset to be committed
57+
metadata (str): Non-null metadata
58+
"""
1659
OffsetAndMetadata = namedtuple("OffsetAndMetadata",
1760
# TODO add leaderEpoch: OffsetAndMetadata(offset, leaderEpoch, metadata)
1861
["offset", "metadata"])
1962

63+
64+
"""An offset and timestamp tuple
65+
66+
Keyword Arguments:
67+
offset (int): An offset
68+
timestamp (int): The timestamp associated to the offset
69+
"""
2070
OffsetAndTimestamp = namedtuple("OffsetAndTimestamp",
2171
["offset", "timestamp"])
2272

2373

24-
# Define retry policy for async producer
25-
# Limit value: int >= 0, 0 means no retries
74+
"""Define retry policy for async producer
75+
76+
Keyword Arguments:
77+
Limit (int): Number of retries. limit >= 0, 0 means no retries
78+
backoff_ms (int): Milliseconds to backoff.
79+
retry_on_timeouts:
80+
"""
2681
RetryOptions = namedtuple("RetryOptions",
2782
["limit", "backoff_ms", "retry_on_timeouts"])

0 commit comments

Comments
 (0)