kafka-python 3.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (373) hide show
  1. kafka/__init__.py +34 -0
  2. kafka/__main__.py +5 -0
  3. kafka/admin/__init__.py +29 -0
  4. kafka/admin/__main__.py +5 -0
  5. kafka/admin/_acls.py +355 -0
  6. kafka/admin/_cluster.py +359 -0
  7. kafka/admin/_configs.py +479 -0
  8. kafka/admin/_groups.py +754 -0
  9. kafka/admin/_partitions.py +595 -0
  10. kafka/admin/_topics.py +281 -0
  11. kafka/admin/_transactions.py +450 -0
  12. kafka/admin/_users.py +194 -0
  13. kafka/admin/client.py +373 -0
  14. kafka/benchmarks/__init__.py +0 -0
  15. kafka/benchmarks/consumer_performance.py +138 -0
  16. kafka/benchmarks/load_example.py +109 -0
  17. kafka/benchmarks/producer_encode_path.py +201 -0
  18. kafka/benchmarks/producer_performance.py +161 -0
  19. kafka/benchmarks/profile_protocol.py +138 -0
  20. kafka/benchmarks/protocol_old_vs_new.py +447 -0
  21. kafka/benchmarks/record_batch_compose.py +77 -0
  22. kafka/benchmarks/record_batch_read.py +82 -0
  23. kafka/benchmarks/varint_speed.py +426 -0
  24. kafka/cli/__init__.py +36 -0
  25. kafka/cli/admin/__init__.py +117 -0
  26. kafka/cli/admin/acls/__init__.py +9 -0
  27. kafka/cli/admin/acls/common.py +76 -0
  28. kafka/cli/admin/acls/create.py +19 -0
  29. kafka/cli/admin/acls/delete.py +23 -0
  30. kafka/cli/admin/acls/describe.py +16 -0
  31. kafka/cli/admin/cluster/__init__.py +14 -0
  32. kafka/cli/admin/cluster/describe.py +11 -0
  33. kafka/cli/admin/cluster/describe_quorum.py +11 -0
  34. kafka/cli/admin/cluster/features.py +52 -0
  35. kafka/cli/admin/cluster/log_dirs.py +43 -0
  36. kafka/cli/admin/cluster/versions.py +33 -0
  37. kafka/cli/admin/configs/__init__.py +10 -0
  38. kafka/cli/admin/configs/alter.py +43 -0
  39. kafka/cli/admin/configs/common.py +17 -0
  40. kafka/cli/admin/configs/describe.py +30 -0
  41. kafka/cli/admin/configs/list.py +16 -0
  42. kafka/cli/admin/configs/reset.py +20 -0
  43. kafka/cli/admin/groups/__init__.py +16 -0
  44. kafka/cli/admin/groups/alter_offsets.py +30 -0
  45. kafka/cli/admin/groups/delete.py +11 -0
  46. kafka/cli/admin/groups/delete_offsets.py +29 -0
  47. kafka/cli/admin/groups/describe.py +11 -0
  48. kafka/cli/admin/groups/list.py +28 -0
  49. kafka/cli/admin/groups/list_offsets.py +29 -0
  50. kafka/cli/admin/groups/remove_members.py +40 -0
  51. kafka/cli/admin/groups/reset_offsets.py +139 -0
  52. kafka/cli/admin/partitions/__init__.py +21 -0
  53. kafka/cli/admin/partitions/alter_reassignments.py +37 -0
  54. kafka/cli/admin/partitions/create.py +27 -0
  55. kafka/cli/admin/partitions/delete_records.py +31 -0
  56. kafka/cli/admin/partitions/describe.py +36 -0
  57. kafka/cli/admin/partitions/elect_leaders.py +53 -0
  58. kafka/cli/admin/partitions/list_offsets.py +88 -0
  59. kafka/cli/admin/partitions/list_reassignments.py +35 -0
  60. kafka/cli/admin/topics/__init__.py +10 -0
  61. kafka/cli/admin/topics/create.py +13 -0
  62. kafka/cli/admin/topics/delete.py +19 -0
  63. kafka/cli/admin/topics/describe.py +18 -0
  64. kafka/cli/admin/topics/list.py +11 -0
  65. kafka/cli/admin/transactions/__init__.py +17 -0
  66. kafka/cli/admin/transactions/abort.py +38 -0
  67. kafka/cli/admin/transactions/describe.py +24 -0
  68. kafka/cli/admin/transactions/describe_producers.py +29 -0
  69. kafka/cli/admin/transactions/find_hanging.py +26 -0
  70. kafka/cli/admin/transactions/list.py +37 -0
  71. kafka/cli/admin/users/__init__.py +8 -0
  72. kafka/cli/admin/users/alter_user_scram_credentials.py +34 -0
  73. kafka/cli/admin/users/describe_user_scram_credentials.py +15 -0
  74. kafka/cli/common.py +95 -0
  75. kafka/cli/consumer/__init__.py +63 -0
  76. kafka/cli/producer/__init__.py +57 -0
  77. kafka/cluster.py +824 -0
  78. kafka/codec.py +325 -0
  79. kafka/consumer/__init__.py +5 -0
  80. kafka/consumer/__main__.py +5 -0
  81. kafka/consumer/fetcher.py +2012 -0
  82. kafka/consumer/group.py +1347 -0
  83. kafka/consumer/subscription_state.py +897 -0
  84. kafka/coordinator/__init__.py +0 -0
  85. kafka/coordinator/assignors/__init__.py +0 -0
  86. kafka/coordinator/assignors/abstract.py +90 -0
  87. kafka/coordinator/assignors/cooperative_sticky.py +167 -0
  88. kafka/coordinator/assignors/range.py +81 -0
  89. kafka/coordinator/assignors/roundrobin.py +101 -0
  90. kafka/coordinator/assignors/sticky/StickyAssignorUserData.json +37 -0
  91. kafka/coordinator/assignors/sticky/__init__.py +0 -0
  92. kafka/coordinator/assignors/sticky/partition_movements.py +149 -0
  93. kafka/coordinator/assignors/sticky/sorted_set.py +63 -0
  94. kafka/coordinator/assignors/sticky/sticky_assignor.py +665 -0
  95. kafka/coordinator/assignors/sticky/user_data.py +8 -0
  96. kafka/coordinator/base.py +1215 -0
  97. kafka/coordinator/consumer.py +1224 -0
  98. kafka/coordinator/heartbeat.py +82 -0
  99. kafka/coordinator/subscription.py +34 -0
  100. kafka/errors.py +1004 -0
  101. kafka/future.py +166 -0
  102. kafka/metrics/__init__.py +13 -0
  103. kafka/metrics/compound_stat.py +33 -0
  104. kafka/metrics/dict_reporter.py +81 -0
  105. kafka/metrics/kafka_metric.py +36 -0
  106. kafka/metrics/measurable.py +27 -0
  107. kafka/metrics/measurable_stat.py +13 -0
  108. kafka/metrics/metric_config.py +33 -0
  109. kafka/metrics/metric_name.py +105 -0
  110. kafka/metrics/metrics.py +261 -0
  111. kafka/metrics/metrics_reporter.py +53 -0
  112. kafka/metrics/quota.py +41 -0
  113. kafka/metrics/stat.py +19 -0
  114. kafka/metrics/stats/__init__.py +15 -0
  115. kafka/metrics/stats/avg.py +24 -0
  116. kafka/metrics/stats/count.py +17 -0
  117. kafka/metrics/stats/histogram.py +99 -0
  118. kafka/metrics/stats/max_stat.py +17 -0
  119. kafka/metrics/stats/min_stat.py +19 -0
  120. kafka/metrics/stats/percentile.py +14 -0
  121. kafka/metrics/stats/percentiles.py +75 -0
  122. kafka/metrics/stats/rate.py +118 -0
  123. kafka/metrics/stats/sampled_stat.py +99 -0
  124. kafka/metrics/stats/sensor.py +136 -0
  125. kafka/metrics/stats/total.py +15 -0
  126. kafka/net/__init__.py +19 -0
  127. kafka/net/compat.py +165 -0
  128. kafka/net/connection.py +593 -0
  129. kafka/net/http_connect.py +144 -0
  130. kafka/net/inet.py +122 -0
  131. kafka/net/manager.py +451 -0
  132. kafka/net/metrics.py +149 -0
  133. kafka/net/sasl/__init__.py +32 -0
  134. kafka/net/sasl/abc.py +28 -0
  135. kafka/net/sasl/gssapi.py +95 -0
  136. kafka/net/sasl/msk.py +245 -0
  137. kafka/net/sasl/oauth.py +98 -0
  138. kafka/net/sasl/plain.py +42 -0
  139. kafka/net/sasl/scram.py +135 -0
  140. kafka/net/sasl/sspi.py +111 -0
  141. kafka/net/selector.py +644 -0
  142. kafka/net/socks5.py +262 -0
  143. kafka/net/transport.py +415 -0
  144. kafka/net/wakeup_notifier.py +72 -0
  145. kafka/partitioner/__init__.py +8 -0
  146. kafka/partitioner/abc.py +8 -0
  147. kafka/partitioner/default.py +89 -0
  148. kafka/partitioner/sticky.py +109 -0
  149. kafka/producer/__init__.py +5 -0
  150. kafka/producer/__main__.py +5 -0
  151. kafka/producer/future.py +101 -0
  152. kafka/producer/kafka.py +1123 -0
  153. kafka/producer/producer_batch.py +192 -0
  154. kafka/producer/record_accumulator.py +647 -0
  155. kafka/producer/sender.py +884 -0
  156. kafka/producer/transaction_manager.py +1326 -0
  157. kafka/protocol/__init__.py +0 -0
  158. kafka/protocol/admin/__init__.py +29 -0
  159. kafka/protocol/admin/acl.py +83 -0
  160. kafka/protocol/admin/acl.pyi +375 -0
  161. kafka/protocol/admin/client_quotas.py +14 -0
  162. kafka/protocol/admin/client_quotas.pyi +265 -0
  163. kafka/protocol/admin/cluster.py +31 -0
  164. kafka/protocol/admin/cluster.pyi +620 -0
  165. kafka/protocol/admin/configs.py +22 -0
  166. kafka/protocol/admin/configs.pyi +437 -0
  167. kafka/protocol/admin/groups.py +24 -0
  168. kafka/protocol/admin/groups.pyi +261 -0
  169. kafka/protocol/admin/topics.py +53 -0
  170. kafka/protocol/admin/topics.pyi +982 -0
  171. kafka/protocol/admin/transactions.py +18 -0
  172. kafka/protocol/admin/transactions.pyi +311 -0
  173. kafka/protocol/admin/users.py +14 -0
  174. kafka/protocol/admin/users.pyi +223 -0
  175. kafka/protocol/api_data.py +125 -0
  176. kafka/protocol/api_header.py +55 -0
  177. kafka/protocol/api_key.py +97 -0
  178. kafka/protocol/api_message.py +277 -0
  179. kafka/protocol/broker_version_data.py +246 -0
  180. kafka/protocol/consumer/__init__.py +13 -0
  181. kafka/protocol/consumer/fetch.py +16 -0
  182. kafka/protocol/consumer/fetch.pyi +298 -0
  183. kafka/protocol/consumer/group.py +38 -0
  184. kafka/protocol/consumer/group.pyi +824 -0
  185. kafka/protocol/consumer/metadata.py +30 -0
  186. kafka/protocol/consumer/metadata.pyi +89 -0
  187. kafka/protocol/consumer/offsets.py +75 -0
  188. kafka/protocol/consumer/offsets.pyi +288 -0
  189. kafka/protocol/data_container.py +166 -0
  190. kafka/protocol/frame.py +30 -0
  191. kafka/protocol/generate_stubs.py +468 -0
  192. kafka/protocol/metadata/__init__.py +10 -0
  193. kafka/protocol/metadata/api_versions.py +41 -0
  194. kafka/protocol/metadata/api_versions.pyi +128 -0
  195. kafka/protocol/metadata/find_coordinator.py +19 -0
  196. kafka/protocol/metadata/find_coordinator.pyi +105 -0
  197. kafka/protocol/metadata/metadata.py +34 -0
  198. kafka/protocol/metadata/metadata.pyi +160 -0
  199. kafka/protocol/old/__init__.py +0 -0
  200. kafka/protocol/old/abstract.py +17 -0
  201. kafka/protocol/old/add_offsets_to_txn.py +54 -0
  202. kafka/protocol/old/add_partitions_to_txn.py +71 -0
  203. kafka/protocol/old/admin.py +1086 -0
  204. kafka/protocol/old/api.py +205 -0
  205. kafka/protocol/old/api_versions.py +133 -0
  206. kafka/protocol/old/commit.py +355 -0
  207. kafka/protocol/old/consumer_protocol.py +36 -0
  208. kafka/protocol/old/end_txn.py +53 -0
  209. kafka/protocol/old/fetch.py +408 -0
  210. kafka/protocol/old/find_coordinator.py +72 -0
  211. kafka/protocol/old/group.py +451 -0
  212. kafka/protocol/old/init_producer_id.py +42 -0
  213. kafka/protocol/old/list_offsets.py +186 -0
  214. kafka/protocol/old/metadata.py +290 -0
  215. kafka/protocol/old/offset_for_leader_epoch.py +133 -0
  216. kafka/protocol/old/produce.py +247 -0
  217. kafka/protocol/old/sasl_authenticate.py +38 -0
  218. kafka/protocol/old/sasl_handshake.py +39 -0
  219. kafka/protocol/old/struct.py +87 -0
  220. kafka/protocol/old/txn_offset_commit.py +73 -0
  221. kafka/protocol/old/types.py +440 -0
  222. kafka/protocol/parser.py +191 -0
  223. kafka/protocol/producer/__init__.py +7 -0
  224. kafka/protocol/producer/produce.py +17 -0
  225. kafka/protocol/producer/produce.pyi +197 -0
  226. kafka/protocol/producer/transaction.py +30 -0
  227. kafka/protocol/producer/transaction.pyi +663 -0
  228. kafka/protocol/sasl.py +52 -0
  229. kafka/protocol/sasl.pyi +126 -0
  230. kafka/protocol/schemas/__init__.py +7 -0
  231. kafka/protocol/schemas/fields/__init__.py +7 -0
  232. kafka/protocol/schemas/fields/array.py +127 -0
  233. kafka/protocol/schemas/fields/base.py +156 -0
  234. kafka/protocol/schemas/fields/codecs/__init__.py +12 -0
  235. kafka/protocol/schemas/fields/codecs/encode_buffer.py +82 -0
  236. kafka/protocol/schemas/fields/codecs/tagged_fields.py +109 -0
  237. kafka/protocol/schemas/fields/codecs/types.py +505 -0
  238. kafka/protocol/schemas/fields/codegen.py +40 -0
  239. kafka/protocol/schemas/fields/simple.py +127 -0
  240. kafka/protocol/schemas/fields/struct.py +357 -0
  241. kafka/protocol/schemas/fields/struct_array.py +142 -0
  242. kafka/protocol/schemas/load_json.py +42 -0
  243. kafka/protocol/schemas/resources/AddOffsetsToTxnRequest.json +40 -0
  244. kafka/protocol/schemas/resources/AddOffsetsToTxnResponse.json +35 -0
  245. kafka/protocol/schemas/resources/AddPartitionsToTxnRequest.json +65 -0
  246. kafka/protocol/schemas/resources/AddPartitionsToTxnResponse.json +60 -0
  247. kafka/protocol/schemas/resources/AlterClientQuotasRequest.json +47 -0
  248. kafka/protocol/schemas/resources/AlterClientQuotasResponse.json +41 -0
  249. kafka/protocol/schemas/resources/AlterConfigsRequest.json +43 -0
  250. kafka/protocol/schemas/resources/AlterConfigsResponse.json +39 -0
  251. kafka/protocol/schemas/resources/AlterPartitionReassignmentsRequest.json +42 -0
  252. kafka/protocol/schemas/resources/AlterPartitionReassignmentsResponse.json +47 -0
  253. kafka/protocol/schemas/resources/AlterReplicaLogDirsRequest.json +41 -0
  254. kafka/protocol/schemas/resources/AlterReplicaLogDirsResponse.json +41 -0
  255. kafka/protocol/schemas/resources/AlterUserScramCredentialsRequest.json +45 -0
  256. kafka/protocol/schemas/resources/AlterUserScramCredentialsResponse.json +35 -0
  257. kafka/protocol/schemas/resources/ApiVersionsRequest.json +34 -0
  258. kafka/protocol/schemas/resources/ApiVersionsResponse.json +79 -0
  259. kafka/protocol/schemas/resources/ConsumerProtocolAssignment.json +42 -0
  260. kafka/protocol/schemas/resources/ConsumerProtocolSubscription.json +49 -0
  261. kafka/protocol/schemas/resources/CreateAclsRequest.json +46 -0
  262. kafka/protocol/schemas/resources/CreateAclsResponse.json +37 -0
  263. kafka/protocol/schemas/resources/CreatePartitionsRequest.json +47 -0
  264. kafka/protocol/schemas/resources/CreatePartitionsResponse.json +41 -0
  265. kafka/protocol/schemas/resources/CreateTopicsRequest.json +65 -0
  266. kafka/protocol/schemas/resources/CreateTopicsResponse.json +72 -0
  267. kafka/protocol/schemas/resources/DeleteAclsRequest.json +46 -0
  268. kafka/protocol/schemas/resources/DeleteAclsResponse.json +59 -0
  269. kafka/protocol/schemas/resources/DeleteGroupsRequest.json +30 -0
  270. kafka/protocol/schemas/resources/DeleteGroupsResponse.json +36 -0
  271. kafka/protocol/schemas/resources/DeleteRecordsRequest.json +42 -0
  272. kafka/protocol/schemas/resources/DeleteRecordsResponse.json +43 -0
  273. kafka/protocol/schemas/resources/DeleteTopicsRequest.json +43 -0
  274. kafka/protocol/schemas/resources/DeleteTopicsResponse.json +52 -0
  275. kafka/protocol/schemas/resources/DescribeAclsRequest.json +43 -0
  276. kafka/protocol/schemas/resources/DescribeAclsResponse.json +55 -0
  277. kafka/protocol/schemas/resources/DescribeClientQuotasRequest.json +37 -0
  278. kafka/protocol/schemas/resources/DescribeClientQuotasResponse.json +47 -0
  279. kafka/protocol/schemas/resources/DescribeClusterRequest.json +35 -0
  280. kafka/protocol/schemas/resources/DescribeClusterResponse.json +56 -0
  281. kafka/protocol/schemas/resources/DescribeConfigsRequest.json +42 -0
  282. kafka/protocol/schemas/resources/DescribeConfigsResponse.json +69 -0
  283. kafka/protocol/schemas/resources/DescribeGroupsRequest.json +38 -0
  284. kafka/protocol/schemas/resources/DescribeGroupsResponse.json +74 -0
  285. kafka/protocol/schemas/resources/DescribeLogDirsRequest.json +38 -0
  286. kafka/protocol/schemas/resources/DescribeLogDirsResponse.json +65 -0
  287. kafka/protocol/schemas/resources/DescribeProducersRequest.json +32 -0
  288. kafka/protocol/schemas/resources/DescribeProducersResponse.json +55 -0
  289. kafka/protocol/schemas/resources/DescribeQuorumRequest.json +39 -0
  290. kafka/protocol/schemas/resources/DescribeQuorumResponse.json +82 -0
  291. kafka/protocol/schemas/resources/DescribeTopicPartitionsRequest.json +40 -0
  292. kafka/protocol/schemas/resources/DescribeTopicPartitionsResponse.json +66 -0
  293. kafka/protocol/schemas/resources/DescribeTransactionsRequest.json +27 -0
  294. kafka/protocol/schemas/resources/DescribeTransactionsResponse.json +52 -0
  295. kafka/protocol/schemas/resources/DescribeUserScramCredentialsRequest.json +30 -0
  296. kafka/protocol/schemas/resources/DescribeUserScramCredentialsResponse.json +45 -0
  297. kafka/protocol/schemas/resources/ElectLeadersRequest.json +41 -0
  298. kafka/protocol/schemas/resources/ElectLeadersResponse.json +45 -0
  299. kafka/protocol/schemas/resources/EndTxnRequest.json +43 -0
  300. kafka/protocol/schemas/resources/EndTxnResponse.json +41 -0
  301. kafka/protocol/schemas/resources/FetchRequest.json +125 -0
  302. kafka/protocol/schemas/resources/FetchResponse.json +124 -0
  303. kafka/protocol/schemas/resources/FindCoordinatorRequest.json +43 -0
  304. kafka/protocol/schemas/resources/FindCoordinatorResponse.json +58 -0
  305. kafka/protocol/schemas/resources/HeartbeatRequest.json +39 -0
  306. kafka/protocol/schemas/resources/HeartbeatResponse.json +35 -0
  307. kafka/protocol/schemas/resources/IncrementalAlterConfigsRequest.json +44 -0
  308. kafka/protocol/schemas/resources/IncrementalAlterConfigsResponse.json +38 -0
  309. kafka/protocol/schemas/resources/InitProducerIdRequest.json +50 -0
  310. kafka/protocol/schemas/resources/InitProducerIdResponse.json +47 -0
  311. kafka/protocol/schemas/resources/JoinGroupRequest.json +63 -0
  312. kafka/protocol/schemas/resources/JoinGroupResponse.json +69 -0
  313. kafka/protocol/schemas/resources/LeaveGroupRequest.json +47 -0
  314. kafka/protocol/schemas/resources/LeaveGroupResponse.json +47 -0
  315. kafka/protocol/schemas/resources/ListConfigResourcesRequest.json +31 -0
  316. kafka/protocol/schemas/resources/ListConfigResourcesResponse.json +37 -0
  317. kafka/protocol/schemas/resources/ListGroupsRequest.json +36 -0
  318. kafka/protocol/schemas/resources/ListGroupsResponse.json +49 -0
  319. kafka/protocol/schemas/resources/ListOffsetsRequest.json +72 -0
  320. kafka/protocol/schemas/resources/ListOffsetsResponse.json +71 -0
  321. kafka/protocol/schemas/resources/ListPartitionReassignmentsRequest.json +34 -0
  322. kafka/protocol/schemas/resources/ListPartitionReassignmentsResponse.json +46 -0
  323. kafka/protocol/schemas/resources/ListTransactionsRequest.json +40 -0
  324. kafka/protocol/schemas/resources/ListTransactionsResponse.json +42 -0
  325. kafka/protocol/schemas/resources/MetadataRequest.json +56 -0
  326. kafka/protocol/schemas/resources/MetadataResponse.json +101 -0
  327. kafka/protocol/schemas/resources/OffsetCommitRequest.json +76 -0
  328. kafka/protocol/schemas/resources/OffsetCommitResponse.json +71 -0
  329. kafka/protocol/schemas/resources/OffsetDeleteRequest.json +39 -0
  330. kafka/protocol/schemas/resources/OffsetDeleteResponse.json +42 -0
  331. kafka/protocol/schemas/resources/OffsetFetchRequest.json +76 -0
  332. kafka/protocol/schemas/resources/OffsetFetchResponse.json +107 -0
  333. kafka/protocol/schemas/resources/OffsetForLeaderEpochRequest.json +52 -0
  334. kafka/protocol/schemas/resources/OffsetForLeaderEpochResponse.json +51 -0
  335. kafka/protocol/schemas/resources/ProduceRequest.json +73 -0
  336. kafka/protocol/schemas/resources/ProduceResponse.json +96 -0
  337. kafka/protocol/schemas/resources/RequestHeader.json +44 -0
  338. kafka/protocol/schemas/resources/ResponseHeader.json +26 -0
  339. kafka/protocol/schemas/resources/SaslAuthenticateRequest.json +29 -0
  340. kafka/protocol/schemas/resources/SaslAuthenticateResponse.json +34 -0
  341. kafka/protocol/schemas/resources/SaslHandshakeRequest.json +31 -0
  342. kafka/protocol/schemas/resources/SaslHandshakeResponse.json +32 -0
  343. kafka/protocol/schemas/resources/SyncGroupRequest.json +56 -0
  344. kafka/protocol/schemas/resources/SyncGroupResponse.json +46 -0
  345. kafka/protocol/schemas/resources/TxnOffsetCommitRequest.json +68 -0
  346. kafka/protocol/schemas/resources/TxnOffsetCommitResponse.json +47 -0
  347. kafka/protocol/schemas/resources/UpdateFeaturesRequest.json +43 -0
  348. kafka/protocol/schemas/resources/UpdateFeaturesResponse.json +39 -0
  349. kafka/protocol/schemas/resources/WriteTxnMarkersRequest.json +49 -0
  350. kafka/protocol/schemas/resources/WriteTxnMarkersResponse.json +45 -0
  351. kafka/protocol/schemas/resources/__init__.py +0 -0
  352. kafka/record/__init__.py +3 -0
  353. kafka/record/_crc32c.py +161 -0
  354. kafka/record/abc.py +144 -0
  355. kafka/record/default_records.py +782 -0
  356. kafka/record/legacy_records.py +587 -0
  357. kafka/record/memory_records.py +255 -0
  358. kafka/record/util.py +135 -0
  359. kafka/serializer/__init__.py +4 -0
  360. kafka/serializer/abstract.py +20 -0
  361. kafka/serializer/default.py +16 -0
  362. kafka/serializer/json.py +17 -0
  363. kafka/serializer/wrapper.py +21 -0
  364. kafka/structs.py +69 -0
  365. kafka/util.py +159 -0
  366. kafka/vendor/__init__.py +0 -0
  367. kafka/version.py +1 -0
  368. kafka_python-3.0.0.dist-info/METADATA +319 -0
  369. kafka_python-3.0.0.dist-info/RECORD +373 -0
  370. kafka_python-3.0.0.dist-info/WHEEL +5 -0
  371. kafka_python-3.0.0.dist-info/entry_points.txt +2 -0
  372. kafka_python-3.0.0.dist-info/licenses/LICENSE +202 -0
  373. kafka_python-3.0.0.dist-info/top_level.txt +1 -0
kafka/errors.py ADDED
@@ -0,0 +1,1004 @@
1
+ import inspect
2
+ import sys
3
+
4
+
5
+ class KafkaError(Exception):
6
+ retriable = False
7
+ # whether metadata should be refreshed on error
8
+ invalid_metadata = False
9
+
10
+ def __str__(self):
11
+ if not self.args:
12
+ return self.__class__.__name__
13
+ return '{0}: {1}'.format(self.__class__.__name__,
14
+ super().__str__())
15
+
16
+ def __eq__(self, other):
17
+ return self.__class__ == other.__class__ and self.args == other.args
18
+
19
+
20
+ class RetriableError(KafkaError):
21
+ retriable = True
22
+
23
+
24
+ class InvalidMetadataError(RetriableError):
25
+ invalid_metadata = True
26
+
27
+
28
+ class Cancelled(RetriableError):
29
+ pass
30
+
31
+
32
+ class CommitFailedError(KafkaError):
33
+ def __init__(self, *args):
34
+ if not args:
35
+ args = ("Commit cannot be completed since the group has already"
36
+ " rebalanced and assigned the partitions to another member.",)
37
+ super().__init__(*args)
38
+
39
+
40
+ class IllegalArgumentError(KafkaError):
41
+ pass
42
+
43
+
44
+ class IllegalStateError(KafkaError):
45
+ pass
46
+
47
+
48
+ class KafkaConfigurationError(KafkaError):
49
+ pass
50
+
51
+
52
+ class KafkaConnectionError(InvalidMetadataError):
53
+ pass
54
+
55
+
56
+ class KafkaProtocolError(KafkaError):
57
+ pass
58
+
59
+
60
+ class CorrelationIdError(RetriableError, KafkaProtocolError):
61
+ pass
62
+
63
+
64
+ class InvalidReceiveError(KafkaProtocolError):
65
+ pass
66
+
67
+
68
+ class KafkaTimeoutError(RetriableError):
69
+ pass
70
+
71
+
72
+ class MetadataEmptyBrokerList(RetriableError):
73
+ pass
74
+
75
+
76
+ class NoOffsetForPartitionError(KafkaError):
77
+ pass
78
+
79
+
80
+ class LogTruncationError(KafkaError):
81
+ """The broker's log was truncated past the consumer's current position.
82
+
83
+ Raised by the offset-validation flow (KIP-320) when an
84
+ ``OffsetForLeaderEpoch`` response indicates the consumer has read past
85
+ records that no longer exist under its leader_epoch on the current
86
+ leader - typically the result of an unclean leader election that
87
+ promoted a follower with a shorter log, silently rolling back records
88
+ the consumer thought it had consumed.
89
+
90
+ Distinct from :class:`OffsetOutOfRangeError`, which signals that
91
+ retention/compaction deleted records *below* the consumer's position.
92
+
93
+ ``divergent_offsets`` is a ``dict[TopicPartition, Optional[OffsetAndMetadata]]``:
94
+
95
+ - When the broker reports a concrete diverging endpoint (its end_offset
96
+ for our epoch is below our position), the value is an
97
+ ``OffsetAndMetadata(end_offset, ..., end_epoch)`` - the safe point to
98
+ seek back to.
99
+ - When the broker has no record of our epoch at all (response carried
100
+ ``UNDEFINED_EPOCH`` / ``UNDEFINED_EPOCH_OFFSET``), the value is
101
+ ``None`` - we know truncation occurred but there is no known
102
+ recovery point on this broker.
103
+ """
104
+
105
+ def __init__(self, divergent_offsets, *args):
106
+ self.divergent_offsets = divergent_offsets
107
+ super().__init__(*args or ('Detected truncated partitions: %s' % (divergent_offsets,),))
108
+
109
+
110
+ class NodeNotReadyError(RetriableError):
111
+ pass
112
+
113
+
114
+ class UnknownBrokerIdError(KafkaError):
115
+ pass
116
+
117
+
118
+ class QuotaViolationError(KafkaError):
119
+ pass
120
+
121
+
122
+ class StaleMetadata(InvalidMetadataError):
123
+ pass
124
+
125
+
126
+ class TooManyInFlightRequests(RetriableError):
127
+ pass
128
+
129
+
130
+ class UnrecognizedBrokerVersion(KafkaError):
131
+ pass
132
+
133
+
134
+ class UnsupportedCodecError(KafkaError):
135
+ pass
136
+
137
+
138
+ class TransactionAbortedError(KafkaError):
139
+ """Raised on undrained batches when a transaction is aborted with no
140
+ underlying cause -- the user chose to abort (KIP-654). Non-fatal: the
141
+ producer remains usable for the next transaction."""
142
+ message = 'Failing batch since transaction was aborted'
143
+
144
+
145
+ class BrokerResponseError(KafkaError):
146
+ errno = None
147
+ message = None
148
+ description = None
149
+
150
+ def __str__(self):
151
+ """Add errno to standard KafkaError str"""
152
+ return '[Error {0}] {1}'.format(
153
+ self.errno,
154
+ super().__str__())
155
+
156
+
157
+ class AuthorizationError(BrokerResponseError):
158
+ pass
159
+
160
+
161
+ class NoError(BrokerResponseError):
162
+ errno = 0
163
+ message = 'NO_ERROR'
164
+ description = 'No error--it worked!'
165
+
166
+
167
+ class UnknownError(BrokerResponseError):
168
+ errno = -1
169
+ message = 'UNKNOWN'
170
+ description = 'An unexpected server error.'
171
+
172
+
173
+ class OffsetOutOfRangeError(BrokerResponseError):
174
+ errno = 1
175
+ message = 'OFFSET_OUT_OF_RANGE'
176
+ description = ('The requested offset is outside the range of offsets'
177
+ ' maintained by the server for the given topic/partition.')
178
+
179
+
180
+ class CorruptRecordError(BrokerResponseError):
181
+ errno = 2
182
+ message = 'CORRUPT_MESSAGE'
183
+ description = ('This message has failed its CRC checksum, exceeds the'
184
+ ' valid size, or is otherwise corrupt.')
185
+
186
+ # Backward compatibility
187
+ CorruptRecordException = CorruptRecordError
188
+
189
+
190
+ class UnknownTopicOrPartitionError(InvalidMetadataError, BrokerResponseError):
191
+ errno = 3
192
+ message = 'UNKNOWN_TOPIC_OR_PARTITION'
193
+ description = ('This request is for a topic or partition that does not'
194
+ ' exist on this broker.')
195
+
196
+
197
+ class InvalidFetchRequestError(BrokerResponseError):
198
+ errno = 4
199
+ message = 'INVALID_FETCH_SIZE'
200
+ description = 'The message has a negative size.'
201
+
202
+
203
+ class LeaderNotAvailableError(InvalidMetadataError, BrokerResponseError):
204
+ errno = 5
205
+ message = 'LEADER_NOT_AVAILABLE'
206
+ description = ('This error is thrown if we are in the middle of a'
207
+ ' leadership election and there is currently no leader for'
208
+ ' this partition and hence it is unavailable for writes.')
209
+
210
+
211
+ class NotLeaderForPartitionError(InvalidMetadataError, BrokerResponseError):
212
+ errno = 6
213
+ message = 'NOT_LEADER_FOR_PARTITION'
214
+ description = ('This error is thrown if the client attempts to send'
215
+ ' messages to a replica that is not the leader for some'
216
+ ' partition. It indicates that the clients metadata is out'
217
+ ' of date.')
218
+
219
+
220
+ class RequestTimedOutError(RetriableError, BrokerResponseError):
221
+ errno = 7
222
+ message = 'REQUEST_TIMED_OUT'
223
+ description = ('This error is thrown if the request exceeds the'
224
+ ' user-specified time limit in the request.')
225
+
226
+
227
+ class BrokerNotAvailableError(BrokerResponseError):
228
+ errno = 8
229
+ message = 'BROKER_NOT_AVAILABLE'
230
+ description = ('This is not a client facing error and is used mostly by'
231
+ ' tools when a broker is not alive.')
232
+
233
+
234
+ class ReplicaNotAvailableError(InvalidMetadataError, BrokerResponseError):
235
+ errno = 9
236
+ message = 'REPLICA_NOT_AVAILABLE'
237
+ description = ('If replica is expected on a broker, but is not (this can be'
238
+ ' safely ignored).')
239
+
240
+
241
+ class MessageSizeTooLargeError(BrokerResponseError):
242
+ errno = 10
243
+ message = 'MESSAGE_SIZE_TOO_LARGE'
244
+ description = ('The server has a configurable maximum message size to avoid'
245
+ ' unbounded memory allocation. This error is thrown if the'
246
+ ' client attempt to produce a message larger than this'
247
+ ' maximum.')
248
+
249
+
250
+ class StaleControllerEpochError(BrokerResponseError):
251
+ errno = 11
252
+ message = 'STALE_CONTROLLER_EPOCH'
253
+ description = 'Internal error code for broker-to-broker communication.'
254
+
255
+
256
+ class OffsetMetadataTooLargeError(BrokerResponseError):
257
+ errno = 12
258
+ message = 'OFFSET_METADATA_TOO_LARGE'
259
+ description = ('If you specify a string larger than configured maximum for'
260
+ ' offset metadata.')
261
+
262
+
263
+ class NetworkExceptionError(InvalidMetadataError, BrokerResponseError):
264
+ errno = 13
265
+ message = 'NETWORK_EXCEPTION'
266
+
267
+
268
+ class CoordinatorLoadInProgressError(RetriableError, BrokerResponseError):
269
+ errno = 14
270
+ message = 'COORDINATOR_LOAD_IN_PROGRESS'
271
+ description = ('The broker returns this error code for txn or group requests,'
272
+ ' when the coordinator is loading and hence cant process requests')
273
+
274
+
275
+ class CoordinatorNotAvailableError(RetriableError, BrokerResponseError):
276
+ errno = 15
277
+ message = 'COORDINATOR_NOT_AVAILABLE'
278
+ description = ('The broker returns this error code for consumer and transaction'
279
+ ' requests if the offsets topic has not yet been created, or'
280
+ ' if the group/txn coordinator is not active.')
281
+
282
+
283
+ class NotCoordinatorError(RetriableError, BrokerResponseError):
284
+ errno = 16
285
+ message = 'NOT_COORDINATOR'
286
+ description = ('The broker returns this error code if it is not the correct'
287
+ ' coordinator for the specified consumer or transaction group')
288
+
289
+
290
+ class InvalidTopicError(BrokerResponseError):
291
+ errno = 17
292
+ message = 'INVALID_TOPIC'
293
+ description = ('For a request which attempts to access an invalid topic'
294
+ ' (e.g. one which has an illegal name), or if an attempt'
295
+ ' is made to write to an internal topic (such as the'
296
+ ' consumer offsets topic).')
297
+
298
+
299
+ class RecordListTooLargeError(BrokerResponseError):
300
+ errno = 18
301
+ message = 'RECORD_LIST_TOO_LARGE'
302
+ description = ('If a message batch in a produce request exceeds the maximum'
303
+ ' configured segment size.')
304
+
305
+
306
+ class NotEnoughReplicasError(RetriableError, BrokerResponseError):
307
+ errno = 19
308
+ message = 'NOT_ENOUGH_REPLICAS'
309
+ description = ('Returned from a produce request when the number of in-sync'
310
+ ' replicas is lower than the configured minimum and'
311
+ ' requiredAcks is -1.')
312
+
313
+
314
+ class NotEnoughReplicasAfterAppendError(RetriableError, BrokerResponseError):
315
+ errno = 20
316
+ message = 'NOT_ENOUGH_REPLICAS_AFTER_APPEND'
317
+ description = ('Returned from a produce request when the message was'
318
+ ' written to the log, but with fewer in-sync replicas than'
319
+ ' required.')
320
+
321
+
322
+ class InvalidRequiredAcksError(BrokerResponseError):
323
+ errno = 21
324
+ message = 'INVALID_REQUIRED_ACKS'
325
+ description = ('Returned from a produce request if the requested'
326
+ ' requiredAcks is invalid (anything other than -1, 1, or 0).')
327
+
328
+
329
+ class IllegalGenerationError(BrokerResponseError):
330
+ errno = 22
331
+ message = 'ILLEGAL_GENERATION'
332
+ description = ('Returned from group membership requests (such as heartbeats)'
333
+ ' when the generation id provided in the request is not the'
334
+ ' current generation.')
335
+
336
+
337
+ class InconsistentGroupProtocolError(BrokerResponseError):
338
+ errno = 23
339
+ message = 'INCONSISTENT_GROUP_PROTOCOL'
340
+ description = ('Returned in join group when the member provides a protocol'
341
+ ' type or set of protocols which is not compatible with the'
342
+ ' current group.')
343
+
344
+
345
+ class InvalidGroupIdError(BrokerResponseError):
346
+ errno = 24
347
+ message = 'INVALID_GROUP_ID'
348
+ description = 'Returned in join group when the groupId is empty or null.'
349
+
350
+
351
+ class UnknownMemberIdError(BrokerResponseError):
352
+ errno = 25
353
+ message = 'UNKNOWN_MEMBER_ID'
354
+ description = ('Returned from group requests (offset commits/fetches,'
355
+ ' heartbeats, etc) when the memberId is not in the current'
356
+ ' generation.')
357
+
358
+
359
+ class InvalidSessionTimeoutError(BrokerResponseError):
360
+ errno = 26
361
+ message = 'INVALID_SESSION_TIMEOUT'
362
+ description = ('Return in join group when the requested session timeout is'
363
+ ' outside of the allowed range on the broker')
364
+
365
+
366
+ class RebalanceInProgressError(BrokerResponseError):
367
+ errno = 27
368
+ message = 'REBALANCE_IN_PROGRESS'
369
+ description = ('Returned in heartbeat requests when the coordinator has'
370
+ ' begun rebalancing the group. This indicates to the client'
371
+ ' that it should rejoin the group.')
372
+
373
+
374
+ class InvalidCommitOffsetSizeError(BrokerResponseError):
375
+ errno = 28
376
+ message = 'INVALID_COMMIT_OFFSET_SIZE'
377
+ description = ('This error indicates that an offset commit was rejected'
378
+ ' because of oversize metadata.')
379
+
380
+
381
+ class TopicAuthorizationFailedError(AuthorizationError):
382
+ errno = 29
383
+ message = 'TOPIC_AUTHORIZATION_FAILED'
384
+ description = ('Returned by the broker when the client is not authorized to'
385
+ ' access the requested topic.')
386
+
387
+
388
+ class GroupAuthorizationFailedError(AuthorizationError):
389
+ errno = 30
390
+ message = 'GROUP_AUTHORIZATION_FAILED'
391
+ description = ('Returned by the broker when the client is not authorized to'
392
+ ' access a particular groupId.')
393
+
394
+
395
+ class ClusterAuthorizationFailedError(AuthorizationError):
396
+ errno = 31
397
+ message = 'CLUSTER_AUTHORIZATION_FAILED'
398
+ description = ('Returned by the broker when the client is not authorized to'
399
+ ' use an inter-broker or administrative API.')
400
+
401
+
402
+ class InvalidTimestampError(BrokerResponseError):
403
+ errno = 32
404
+ message = 'INVALID_TIMESTAMP'
405
+ description = 'The timestamp of the message is out of acceptable range.'
406
+
407
+
408
+ class UnsupportedSaslMechanismError(BrokerResponseError):
409
+ errno = 33
410
+ message = 'UNSUPPORTED_SASL_MECHANISM'
411
+ description = 'The broker does not support the requested SASL mechanism.'
412
+
413
+
414
+ class IllegalSaslStateError(BrokerResponseError):
415
+ errno = 34
416
+ message = 'ILLEGAL_SASL_STATE'
417
+ description = 'Request is not valid given the current SASL state.'
418
+
419
+
420
+ class UnsupportedVersionError(BrokerResponseError):
421
+ errno = 35
422
+ message = 'UNSUPPORTED_VERSION'
423
+ description = 'The version of API is not supported.'
424
+
425
+
426
+ class IncompatibleBrokerVersion(UnsupportedVersionError):
427
+ """Synthetic error raised by client"""
428
+
429
+
430
+ class TopicAlreadyExistsError(BrokerResponseError):
431
+ errno = 36
432
+ message = 'TOPIC_ALREADY_EXISTS'
433
+ description = 'Topic with this name already exists.'
434
+
435
+
436
+ class InvalidPartitionsError(BrokerResponseError):
437
+ errno = 37
438
+ message = 'INVALID_PARTITIONS'
439
+ description = 'Number of partitions is invalid.'
440
+
441
+
442
+ class InvalidReplicationFactorError(BrokerResponseError):
443
+ errno = 38
444
+ message = 'INVALID_REPLICATION_FACTOR'
445
+ description = 'Replication-factor is invalid.'
446
+
447
+
448
+ class InvalidReplicationAssignmentError(BrokerResponseError):
449
+ errno = 39
450
+ message = 'INVALID_REPLICATION_ASSIGNMENT'
451
+ description = 'Replication assignment is invalid.'
452
+
453
+
454
+ class InvalidConfigurationError(BrokerResponseError):
455
+ errno = 40
456
+ message = 'INVALID_CONFIG'
457
+ description = 'Configuration is invalid.'
458
+
459
+
460
+ class NotControllerError(RetriableError, BrokerResponseError):
461
+ errno = 41
462
+ message = 'NOT_CONTROLLER'
463
+ description = 'This is not the correct controller for this cluster.'
464
+
465
+
466
+ class InvalidRequestError(BrokerResponseError):
467
+ errno = 42
468
+ message = 'INVALID_REQUEST'
469
+ description = ('This most likely occurs because of a request being'
470
+ ' malformed by the client library or the message was'
471
+ ' sent to an incompatible broker. See the broker logs'
472
+ ' for more details.')
473
+
474
+
475
+ class UnsupportedForMessageFormatError(BrokerResponseError):
476
+ errno = 43
477
+ message = 'UNSUPPORTED_FOR_MESSAGE_FORMAT'
478
+ description = ('The message format version on the broker does not'
479
+ ' support this request.')
480
+
481
+
482
+ class PolicyViolationError(BrokerResponseError):
483
+ errno = 44
484
+ message = 'POLICY_VIOLATION'
485
+ description = 'Request parameters do not satisfy the configured policy.'
486
+
487
+
488
+ class OutOfOrderSequenceNumberError(BrokerResponseError):
489
+ errno = 45
490
+ message = 'OUT_OF_ORDER_SEQUENCE_NUMBER'
491
+ description = 'The broker received an out of order sequence number.'
492
+
493
+
494
+ class DuplicateSequenceNumberError(BrokerResponseError):
495
+ errno = 46
496
+ message = 'DUPLICATE_SEQUENCE_NUMBER'
497
+ description = 'The broker received a duplicate sequence number.'
498
+
499
+
500
+ class InvalidProducerEpochError(BrokerResponseError):
501
+ errno = 47
502
+ message = 'INVALID_PRODUCER_EPOCH'
503
+ description = 'Producer attempted to produce with an old epoch.'
504
+
505
+
506
+ class InvalidTxnStateError(BrokerResponseError):
507
+ errno = 48
508
+ message = 'INVALID_TXN_STATE'
509
+ description = 'The producer attempted a transactional operation in an invalid state.'
510
+
511
+
512
+ class InvalidProducerIdMappingError(BrokerResponseError):
513
+ errno = 49
514
+ message = 'INVALID_PRODUCER_ID_MAPPING'
515
+ description = 'The producer attempted to use a producer id which is not currently assigned to its transactional id.'
516
+
517
+
518
+ class InvalidTransactionTimeoutError(BrokerResponseError):
519
+ errno = 50
520
+ message = 'INVALID_TRANSACTION_TIMEOUT'
521
+ description = 'The transaction timeout is larger than the maximum value allowed by the broker (as configured by transaction.max.timeout.ms).'
522
+
523
+
524
+ class ConcurrentTransactionsError(RetriableError, BrokerResponseError):
525
+ errno = 51
526
+ message = 'CONCURRENT_TRANSACTIONS'
527
+ description = 'The producer attempted to update a transaction while another concurrent operation on the same transaction was ongoing.'
528
+
529
+
530
+ class TransactionCoordinatorFencedError(BrokerResponseError):
531
+ errno = 52
532
+ message = 'TRANSACTION_COORDINATOR_FENCED'
533
+ description = 'Indicates that the transaction coordinator sending a WriteTxnMarker is no longer the current coordinator for a given producer.'
534
+
535
+
536
+ class TransactionalIdAuthorizationFailedError(AuthorizationError):
537
+ errno = 53
538
+ message = 'TRANSACTIONAL_ID_AUTHORIZATION_FAILED'
539
+ description = 'Transactional Id authorization failed.'
540
+
541
+
542
+ class SecurityDisabledError(BrokerResponseError):
543
+ errno = 54
544
+ message = 'SECURITY_DISABLED'
545
+ description = 'Security features are disabled.'
546
+
547
+
548
+ class OperationNotAttemptedError(BrokerResponseError):
549
+ errno = 55
550
+ message = 'OPERATION_NOT_ATTEMPTED'
551
+ description = 'The broker did not attempt to execute this operation. This may happen for batched RPCs where some operations in the batch failed, causing the broker to respond without trying the rest.'
552
+
553
+
554
+ class KafkaStorageError(InvalidMetadataError, BrokerResponseError):
555
+ errno = 56
556
+ message = 'KAFKA_STORAGE_ERROR'
557
+ description = 'Disk error when trying to access log file on the disk.'
558
+
559
+
560
+ class LogDirNotFoundError(BrokerResponseError):
561
+ errno = 57
562
+ message = 'LOG_DIR_NOT_FOUND'
563
+ description = 'The user-specified log directory is not found in the broker config.'
564
+
565
+
566
+ class SaslAuthenticationFailedError(BrokerResponseError):
567
+ errno = 58
568
+ message = 'SASL_AUTHENTICATION_FAILED'
569
+ description = 'SASL Authentication failed.'
570
+
571
+
572
+ class UnknownProducerIdError(BrokerResponseError):
573
+ errno = 59
574
+ message = 'UNKNOWN_PRODUCER_ID'
575
+ description = 'This exception is raised by the broker if it could not locate the producer metadata associated with the producerId in question. This could happen if, for instance, the producer\'s records were deleted because their retention time had elapsed. Once the last records of the producerId are removed, the producer\'s metadata is removed from the broker, and future appends by the producer will return this exception.'
576
+
577
+
578
+ class ReassignmentInProgressError(BrokerResponseError):
579
+ errno = 60
580
+ message = 'REASSIGNMENT_IN_PROGRESS'
581
+ description = 'A partition reassignment is in progress.'
582
+
583
+
584
+ class DelegationTokenAuthDisabledError(BrokerResponseError):
585
+ errno = 61
586
+ message = 'DELEGATION_TOKEN_AUTH_DISABLED'
587
+ description = 'Delegation Token feature is not enabled.'
588
+
589
+
590
+ class DelegationTokenNotFoundError(BrokerResponseError):
591
+ errno = 62
592
+ message = 'DELEGATION_TOKEN_NOT_FOUND'
593
+ description = 'Delegation Token is not found on server.'
594
+
595
+
596
+ class DelegationTokenOwnerMismatchError(BrokerResponseError):
597
+ errno = 63
598
+ message = 'DELEGATION_TOKEN_OWNER_MISMATCH'
599
+ description = 'Specified Principal is not valid Owner/Renewer.'
600
+
601
+
602
+ class DelegationTokenRequestNotAllowedError(BrokerResponseError):
603
+ errno = 64
604
+ message = 'DELEGATION_TOKEN_REQUEST_NOT_ALLOWED'
605
+ description = 'Delegation Token requests are not allowed on PLAINTEXT/1-way SSL channels and on delegation token authenticated channels.'
606
+
607
+
608
+ class DelegationTokenAuthorizationFailedError(AuthorizationError):
609
+ errno = 65
610
+ message = 'DELEGATION_TOKEN_AUTHORIZATION_FAILED'
611
+ description = 'Delegation Token authorization failed.'
612
+
613
+
614
+ class DelegationTokenExpiredError(BrokerResponseError):
615
+ errno = 66
616
+ message = 'DELEGATION_TOKEN_EXPIRED'
617
+ description = 'Delegation Token is expired.'
618
+
619
+
620
+ class InvalidPrincipalTypeError(BrokerResponseError):
621
+ errno = 67
622
+ message = 'INVALID_PRINCIPAL_TYPE'
623
+ description = 'Supplied principalType is not supported.'
624
+
625
+
626
+ class NonEmptyGroupError(BrokerResponseError):
627
+ errno = 68
628
+ message = 'NON_EMPTY_GROUP'
629
+ description = 'The group is not empty.'
630
+
631
+
632
+ class GroupIdNotFoundError(BrokerResponseError):
633
+ errno = 69
634
+ message = 'GROUP_ID_NOT_FOUND'
635
+ description = 'The group id does not exist.'
636
+
637
+
638
+ class FetchSessionIdNotFoundError(RetriableError, BrokerResponseError):
639
+ errno = 70
640
+ message = 'FETCH_SESSION_ID_NOT_FOUND'
641
+ description = 'The fetch session ID was not found.'
642
+
643
+
644
+ class InvalidFetchSessionEpochError(RetriableError, BrokerResponseError):
645
+ errno = 71
646
+ message = 'INVALID_FETCH_SESSION_EPOCH'
647
+ description = 'The fetch session epoch is invalid.'
648
+
649
+
650
+ class ListenerNotFoundError(InvalidMetadataError, BrokerResponseError):
651
+ errno = 72
652
+ message = 'LISTENER_NOT_FOUND'
653
+ description = 'There is no listener on the leader broker that matches the listener on which metadata request was processed.'
654
+
655
+
656
+ class TopicDeletionDisabledError(BrokerResponseError):
657
+ errno = 73
658
+ message = 'TOPIC_DELETION_DISABLED'
659
+ description = 'Topic deletion is disabled.'
660
+
661
+
662
+ class FencedLeaderEpochError(InvalidMetadataError, BrokerResponseError):
663
+ errno = 74
664
+ message = 'FENCED_LEADER_EPOCH'
665
+ description = 'The leader epoch in the request is older than the epoch on the broker.'
666
+
667
+
668
+ class UnknownLeaderEpochError(InvalidMetadataError, BrokerResponseError):
669
+ errno = 75
670
+ message = 'UNKNOWN_LEADER_EPOCH'
671
+ description = 'The leader epoch in the request is newer than the epoch on the broker.'
672
+
673
+
674
+ class UnsupportedCompressionTypeError(BrokerResponseError):
675
+ errno = 76
676
+ message = 'UNSUPPORTED_COMPRESSION_TYPE'
677
+ description = 'The requesting client does not support the compression type of given partition.'
678
+
679
+
680
+ class StaleBrokerEpochError(BrokerResponseError):
681
+ errno = 77
682
+ message = 'STALE_BROKER_EPOCH'
683
+ description = 'Broker epoch has changed.'
684
+
685
+
686
+ class OffsetNotAvailableError(RetriableError, BrokerResponseError):
687
+ errno = 78
688
+ message = 'OFFSET_NOT_AVAILABLE'
689
+ description = 'The leader high watermark has not caught up from a recent leader election so the offsets cannot be guaranteed to be monotonically increasing.'
690
+
691
+
692
+ class MemberIdRequiredError(BrokerResponseError):
693
+ errno = 79
694
+ message = 'MEMBER_ID_REQUIRED'
695
+ description = 'The group member needs to have a valid member id before actually entering a consumer group.'
696
+
697
+
698
+ class PreferredLeaderNotAvailableError(InvalidMetadataError, BrokerResponseError):
699
+ errno = 80
700
+ message = 'PREFERRED_LEADER_NOT_AVAILABLE'
701
+ description = 'The preferred leader was not available.'
702
+
703
+
704
+ class GroupMaxSizeReachedError(BrokerResponseError):
705
+ errno = 81
706
+ message = 'GROUP_MAX_SIZE_REACHED'
707
+ description = 'The consumer group has reached its max size.'
708
+
709
+
710
+ class FencedInstanceIdError(BrokerResponseError):
711
+ errno = 82
712
+ message = 'FENCED_INSTANCE_ID'
713
+ description = 'The broker rejected this static consumer since another consumer with the same group.instance.id has registered with a different member.id.'
714
+
715
+
716
+ class EligibleLeadersNotAvailableError(InvalidMetadataError, BrokerResponseError):
717
+ errno = 83
718
+ message = 'ELIGIBLE_LEADERS_NOT_AVAILABLE'
719
+ description = 'Eligible topic partition leaders are not available.'
720
+
721
+
722
+ class ElectionNotNeededError(InvalidMetadataError, BrokerResponseError):
723
+ errno = 84
724
+ message = 'ELECTION_NOT_NEEDED'
725
+ description = 'Leader election not needed for topic partition.'
726
+
727
+
728
+ class NoReassignmentInProgressError(BrokerResponseError):
729
+ errno = 85
730
+ message = 'NO_REASSIGNMENT_IN_PROGRESS'
731
+ description = 'No partition reassignment is in progress.'
732
+
733
+
734
+ class GroupSubscribedToTopicError(BrokerResponseError):
735
+ errno = 86
736
+ message = 'GROUP_SUBSCRIBED_TO_TOPIC'
737
+ description = 'Deleting offsets of a topic is forbidden while the consumer group is actively subscribed to it.'
738
+
739
+
740
+ class InvalidRecordError(BrokerResponseError):
741
+ errno = 87
742
+ message = 'INVALID_RECORD'
743
+ description = 'This record has failed the validation on broker and hence will be rejected.'
744
+
745
+
746
+ class UnstableOffsetCommitError(RetriableError, BrokerResponseError):
747
+ errno = 88
748
+ message = 'UNSTABLE_OFFSET_COMMIT'
749
+ description = 'There are unstable offsets that need to be cleared.'
750
+
751
+
752
+ class ThrottlingQuotaExceededError(RetriableError, BrokerResponseError):
753
+ errno = 89
754
+ message = 'THROTTLING_QUOTA_EXCEEDED'
755
+ description = 'The throttling quota has been exceeded.'
756
+
757
+
758
+ class ProducerFencedError(BrokerResponseError):
759
+ errno = 90
760
+ message = 'PRODUCER_FENCED'
761
+ description = 'There is a newer producer with the same transactionalId which fences the current one.'
762
+
763
+
764
+ class ResourceNotFoundError(BrokerResponseError):
765
+ errno = 91
766
+ message = 'RESOURCE_NOT_FOUND'
767
+ description = 'A request illegally referred to a resource that does not exist.'
768
+
769
+
770
+ class DuplicateResourceError(BrokerResponseError):
771
+ errno = 92
772
+ message = 'DUPLICATE_RESOURCE'
773
+ description = 'A request illegally referred to the same resource twice.'
774
+
775
+
776
+ class UnacceptableCredentialError(BrokerResponseError):
777
+ errno = 93
778
+ message = 'UNACCEPTABLE_CREDENTIAL'
779
+ description = 'Requested credential would not meet criteria for acceptability.'
780
+
781
+
782
+ class InconsistentVoterSetError(BrokerResponseError):
783
+ errno = 94
784
+ message = 'INCONSISTENT_VOTER_SET'
785
+ description = 'Indicates that the either the sender or recipient of a voter-only request is not one of the expected voters.'
786
+
787
+
788
+ class InvalidUpdateVersionError(BrokerResponseError):
789
+ errno = 95
790
+ message = 'INVALID_UPDATE_VERSION'
791
+ description = 'The given update version was invalid.'
792
+
793
+
794
+ class FeatureUpdateFailedError(BrokerResponseError):
795
+ errno = 96
796
+ message = 'FEATURE_UPDATE_FAILED'
797
+ description = 'Unable to update finalized features due to an unexpected server error.'
798
+
799
+
800
+ class PrincipalDeserializationFailureError(BrokerResponseError):
801
+ errno = 97
802
+ message = 'PRINCIPAL_DESERIALIZATION_FAILURE'
803
+ description = 'Request principal deserialization failed during forwarding. This indicates an internal error on the broker cluster security setup.'
804
+
805
+
806
+ class SnapshotNotFoundError(BrokerResponseError):
807
+ errno = 98
808
+ message = 'SNAPSHOT_NOT_FOUND'
809
+ description = 'Requested snapshot was not found.'
810
+
811
+
812
+ class PositionOutOfRangeError(BrokerResponseError):
813
+ errno = 99
814
+ message = 'POSITION_OUT_OF_RANGE'
815
+ description = 'Requested position is not greater than or equal to zero, and less than the size of the snapshot.'
816
+
817
+
818
+ class UnknownTopicIdError(InvalidMetadataError, BrokerResponseError):
819
+ errno = 100
820
+ message = 'UNKNOWN_TOPIC_ID'
821
+ description = 'This server does not host this topic ID.'
822
+
823
+
824
+ class DuplicateBrokerRegistrationError(BrokerResponseError):
825
+ errno = 101
826
+ message = 'DUPLICATE_BROKER_REGISTRATION'
827
+ description = 'This broker ID is already in use.'
828
+
829
+
830
+ class BrokerIdNotRegisteredError(BrokerResponseError):
831
+ errno = 102
832
+ message = 'BROKER_ID_NOT_REGISTERED'
833
+ description = 'The given broker ID was not registered.'
834
+
835
+
836
+ class InconsistentTopicIdError(InvalidMetadataError, BrokerResponseError):
837
+ errno = 103
838
+ message = 'INCONSISTENT_TOPIC_ID'
839
+ description = 'The log\'s topic ID did not match the topic ID in the request.'
840
+
841
+
842
+ class InconsistentClusterIdError(BrokerResponseError):
843
+ errno = 104
844
+ message = 'INCONSISTENT_CLUSTER_ID'
845
+ description = 'The clusterId in the request does not match that found on the server.'
846
+
847
+
848
+ class TransactionalIdNotFoundError(BrokerResponseError):
849
+ errno = 105
850
+ message = 'TRANSACTIONAL_ID_NOT_FOUND'
851
+ description = 'The transactionalId could not be found.'
852
+
853
+
854
+ class FetchSessionTopicIdError(RetriableError, BrokerResponseError):
855
+ errno = 106
856
+ message = 'FETCH_SESSION_TOPIC_ID_ERROR'
857
+ description = 'The fetch session encountered inconsistent topic ID usage.'
858
+
859
+
860
+ class IneligibleReplicaError(BrokerResponseError):
861
+ errno = 107
862
+ message = 'INELIGIBLE_REPLICA'
863
+ description = 'The new ISR contains at least one ineligible replica.'
864
+
865
+
866
+ class NewLeaderElectedError(BrokerResponseError):
867
+ errno = 108
868
+ message = 'NEW_LEADER_ELECTED'
869
+ description = 'The AlterPartition request successfully updated the partition state but the leader has changed.'
870
+
871
+
872
+ class OffsetMovedToTieredStorageError(BrokerResponseError):
873
+ errno = 109
874
+ message = 'OFFSET_MOVED_TO_TIERED_STORAGE'
875
+ description = 'The requested offset is moved to tiered storage.'
876
+
877
+
878
+ class FencedMemberEpochError(BrokerResponseError):
879
+ errno = 110
880
+ message = 'FENCED_MEMBER_EPOCH'
881
+ description = 'The member epoch is fenced by the group coordinator. The member must abandon all its partitions and rejoin.'
882
+
883
+
884
+ class UnreleasedInstanceIdError(BrokerResponseError):
885
+ errno = 111
886
+ message = 'UNRELEASED_INSTANCE_ID'
887
+ description = 'The instance ID is still used by another member in the consumer group. That member must leave first.'
888
+
889
+
890
+ class UnsupportedAssignorError(BrokerResponseError):
891
+ errno = 112
892
+ message = 'UNSUPPORTED_ASSIGNOR'
893
+ description = 'The assignor or its version range is not supported by the consumer group.'
894
+
895
+
896
+ class StaleMemberEpochError(BrokerResponseError):
897
+ errno = 113
898
+ message = 'STALE_MEMBER_EPOCH'
899
+ description = 'The member epoch is stale. The member must retry after receiving its updated member epoch via the ConsumerGroupHeartbeat API.'
900
+
901
+
902
+ class MismatchedEndpointTypeError(BrokerResponseError):
903
+ errno = 114
904
+ message = 'MISMATCHED_ENDPOINT_TYPE'
905
+ description = 'The request was sent to an endpoint of the wrong type.'
906
+
907
+
908
+ class UnsupportedEndpointTypeError(BrokerResponseError):
909
+ errno = 115
910
+ message = 'UNSUPPORTED_ENDPOINT_TYPE'
911
+ description = 'This endpoint type is not supported yet.'
912
+
913
+
914
+ class UnknownControllerIdError(BrokerResponseError):
915
+ errno = 116
916
+ message = 'UNKNOWN_CONTROLLER_ID'
917
+ description = 'This controller ID is not known.'
918
+
919
+
920
+ class UnknownSubscriptionIdError(BrokerResponseError):
921
+ errno = 117
922
+ message = 'UNKNOWN_SUBSCRIPTION_ID'
923
+ description = 'Client sent a push telemetry request with an invalid or outdated subscription ID.'
924
+
925
+
926
+ class TelemetryTooLargeError(BrokerResponseError):
927
+ errno = 118
928
+ message = 'TELEMETRY_TOO_LARGE'
929
+ description = 'Client sent a push telemetry request larger than the maximum size the broker will accept.'
930
+
931
+
932
+ class InvalidRegistrationError(BrokerResponseError):
933
+ errno = 119
934
+ message = 'INVALID_REGISTRATION'
935
+ description = 'The controller has considered the broker registration to be invalid.'
936
+
937
+
938
+ class TransactionAbortableError(BrokerResponseError):
939
+ errno = 120
940
+ message = 'TRANSACTION_ABORTABLE'
941
+ description = 'The server encountered an error with the transaction. The client can abort the transaction to continue using this transactional ID.'
942
+
943
+
944
+ class InvalidRecordStateError(BrokerResponseError):
945
+ errno = 121
946
+ message = 'INVALID_RECORD_STATE'
947
+ description = 'The record state is invalid. The acknowledgement of delivery could not be completed.'
948
+
949
+
950
+ class ShareSessionNotFoundError(RetriableError, BrokerResponseError):
951
+ errno = 122
952
+ message = 'SHARE_SESSION_NOT_FOUND'
953
+ description = 'The share session was not found.'
954
+
955
+
956
+ class InvalidShareSessionEpochError(RetriableError, BrokerResponseError):
957
+ errno = 123
958
+ message = 'INVALID_SHARE_SESSION_EPOCH'
959
+ description = 'The share session epoch is invalid.'
960
+
961
+
962
+ class FencedStateEpochError(BrokerResponseError):
963
+ errno = 124
964
+ message = 'FENCED_STATE_EPOCH'
965
+ description = 'The share coordinator rejected the request because the share-group state epoch did not match.'
966
+
967
+
968
+ class InvalidVoterKeyError(BrokerResponseError):
969
+ errno = 125
970
+ message = 'INVALID_VOTER_KEY'
971
+ description = 'The voter key doesn\'t match the receiving replica\'s key.'
972
+
973
+
974
+ class DuplicateVoterError(BrokerResponseError):
975
+ errno = 126
976
+ message = 'DUPLICATE_VOTER'
977
+ description = 'The voter is already part of the set of voters.'
978
+
979
+
980
+ class VoterNotFoundError(BrokerResponseError):
981
+ errno = 127
982
+ message = 'VOTER_NOT_FOUND'
983
+ description = 'The voter is not part of the set of voters.'
984
+
985
+
986
+ def _iter_broker_errors():
987
+ for name, obj in inspect.getmembers(sys.modules[__name__]):
988
+ if inspect.isclass(obj) and issubclass(obj, BrokerResponseError) and obj != BrokerResponseError:
989
+ yield obj
990
+
991
+
992
+ kafka_errors = dict([(x.errno, x) for x in _iter_broker_errors()])
993
+
994
+
995
+ def for_code(error_code):
996
+ if error_code in kafka_errors:
997
+ return kafka_errors[error_code]
998
+ else:
999
+ # The broker error code was not found in our list. This can happen when connecting
1000
+ # to a newer broker (with new error codes), or simply because our error list is
1001
+ # not complete.
1002
+ #
1003
+ # To avoid dropping the error code, create a dynamic error class w/ errno override.
1004
+ return type('UnrecognizedBrokerError', (UnknownError,), {'errno': error_code})