|
| 1 | +""" Other useful structs """ |
1 | 2 | from __future__ import absolute_import
|
2 | 3 |
|
3 | 4 | from collections import namedtuple
|
4 | 5 |
|
5 | 6 |
|
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 | +""" |
7 | 13 | TopicPartition = namedtuple("TopicPartition",
|
8 | 14 | ["topic", "partition"])
|
9 | 15 |
|
| 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 | +""" |
10 | 27 | BrokerMetadata = namedtuple("BrokerMetadata",
|
11 | 28 | ["nodeId", "host", "port", "rack"])
|
12 | 29 |
|
| 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 | +""" |
13 | 44 | PartitionMetadata = namedtuple("PartitionMetadata",
|
14 | 45 | ["topic", "partition", "leader", "replicas", "isr", "error"])
|
15 | 46 |
|
| 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 | +""" |
16 | 59 | OffsetAndMetadata = namedtuple("OffsetAndMetadata",
|
17 | 60 | # TODO add leaderEpoch: OffsetAndMetadata(offset, leaderEpoch, metadata)
|
18 | 61 | ["offset", "metadata"])
|
19 | 62 |
|
| 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 | +""" |
20 | 70 | OffsetAndTimestamp = namedtuple("OffsetAndTimestamp",
|
21 | 71 | ["offset", "timestamp"])
|
22 | 72 |
|
23 | 73 |
|
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 | +""" |
26 | 81 | RetryOptions = namedtuple("RetryOptions",
|
27 | 82 | ["limit", "backoff_ms", "retry_on_timeouts"])
|
0 commit comments