kafka-python 2.0.1__tar.gz → 2.0.3__tar.gz

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 (143) hide show
  1. {kafka-python-2.0.1 → kafka-python-2.0.3}/CHANGES.md +94 -0
  2. kafka-python-2.0.3/PKG-INFO +244 -0
  3. kafka-python-2.0.3/README.rst +210 -0
  4. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/__init__.py +1 -1
  5. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/admin/client.py +167 -50
  6. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/client_async.py +6 -4
  7. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/codec.py +26 -1
  8. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/conn.py +15 -4
  9. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/consumer/fetcher.py +16 -5
  10. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/consumer/group.py +9 -4
  11. kafka-python-2.0.3/kafka/coordinator/assignors/sticky/partition_movements.py +149 -0
  12. kafka-python-2.0.3/kafka/coordinator/assignors/sticky/sorted_set.py +63 -0
  13. kafka-python-2.0.3/kafka/coordinator/assignors/sticky/sticky_assignor.py +685 -0
  14. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/coordinator/base.py +17 -9
  15. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/coordinator/consumer.py +4 -1
  16. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/errors.py +12 -0
  17. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/producer/future.py +3 -3
  18. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/producer/kafka.py +23 -8
  19. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/producer/record_accumulator.py +4 -4
  20. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/producer/sender.py +23 -6
  21. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/__init__.py +3 -0
  22. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/admin.py +234 -2
  23. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/api.py +42 -1
  24. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/fetch.py +180 -2
  25. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/message.py +7 -3
  26. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/offset.py +87 -2
  27. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/parser.py +7 -14
  28. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/produce.py +77 -2
  29. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/types.py +169 -2
  30. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/record/_crc32c.py +1 -1
  31. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/record/abc.py +1 -1
  32. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/record/default_records.py +9 -2
  33. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/record/legacy_records.py +1 -1
  34. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/record/memory_records.py +1 -1
  35. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/record/util.py +1 -1
  36. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/scram.py +0 -1
  37. kafka-python-2.0.3/kafka/structs.py +87 -0
  38. kafka-python-2.0.3/kafka/vendor/__init__.py +0 -0
  39. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/vendor/selectors34.py +5 -1
  40. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/vendor/six.py +128 -21
  41. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/vendor/socketpair.py +17 -0
  42. kafka-python-2.0.3/kafka/version.py +1 -0
  43. kafka-python-2.0.3/kafka_python.egg-info/PKG-INFO +244 -0
  44. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka_python.egg-info/SOURCES.txt +6 -0
  45. kafka-python-2.0.3/kafka_python.egg-info/requires.txt +12 -0
  46. {kafka-python-2.0.1 → kafka-python-2.0.3}/setup.cfg +1 -1
  47. {kafka-python-2.0.1 → kafka-python-2.0.3}/setup.py +17 -1
  48. kafka-python-2.0.3/test/test_admin_integration.py +314 -0
  49. kafka-python-2.0.3/test/test_assignors.py +871 -0
  50. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_client_async.py +2 -2
  51. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_codec.py +10 -1
  52. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_consumer_integration.py +12 -3
  53. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_coordinator.py +27 -9
  54. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_fetcher.py +18 -0
  55. kafka-python-2.0.3/test/test_partition_movements.py +23 -0
  56. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_producer.py +10 -10
  57. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_protocol.py +53 -1
  58. kafka-python-2.0.1/PKG-INFO +0 -185
  59. kafka-python-2.0.1/README.rst +0 -161
  60. kafka-python-2.0.1/kafka/structs.py +0 -27
  61. kafka-python-2.0.1/kafka/version.py +0 -1
  62. kafka-python-2.0.1/kafka_python.egg-info/PKG-INFO +0 -185
  63. kafka-python-2.0.1/test/test_admin_integration.py +0 -140
  64. kafka-python-2.0.1/test/test_assignors.py +0 -57
  65. {kafka-python-2.0.1 → kafka-python-2.0.3}/AUTHORS.md +0 -0
  66. {kafka-python-2.0.1 → kafka-python-2.0.3}/LICENSE +0 -0
  67. {kafka-python-2.0.1 → kafka-python-2.0.3}/MANIFEST.in +0 -0
  68. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/admin/__init__.py +0 -0
  69. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/admin/acl_resource.py +0 -0
  70. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/admin/config_resource.py +0 -0
  71. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/admin/new_partitions.py +0 -0
  72. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/admin/new_topic.py +0 -0
  73. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/cluster.py +0 -0
  74. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/consumer/__init__.py +0 -0
  75. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/consumer/subscription_state.py +0 -0
  76. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/coordinator/__init__.py +0 -0
  77. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/coordinator/assignors/__init__.py +0 -0
  78. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/coordinator/assignors/abstract.py +0 -0
  79. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/coordinator/assignors/range.py +0 -0
  80. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/coordinator/assignors/roundrobin.py +0 -0
  81. {kafka-python-2.0.1/kafka/vendor → kafka-python-2.0.3/kafka/coordinator/assignors/sticky}/__init__.py +0 -0
  82. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/coordinator/heartbeat.py +0 -0
  83. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/coordinator/protocol.py +0 -0
  84. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/future.py +0 -0
  85. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/__init__.py +0 -0
  86. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/compound_stat.py +0 -0
  87. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/dict_reporter.py +0 -0
  88. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/kafka_metric.py +0 -0
  89. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/measurable.py +0 -0
  90. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/measurable_stat.py +0 -0
  91. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/metric_config.py +0 -0
  92. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/metric_name.py +0 -0
  93. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/metrics.py +0 -0
  94. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/metrics_reporter.py +0 -0
  95. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/quota.py +0 -0
  96. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/stat.py +0 -0
  97. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/stats/__init__.py +0 -0
  98. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/stats/avg.py +0 -0
  99. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/stats/count.py +0 -0
  100. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/stats/histogram.py +0 -0
  101. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/stats/max_stat.py +0 -0
  102. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/stats/min_stat.py +0 -0
  103. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/stats/percentile.py +0 -0
  104. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/stats/percentiles.py +0 -0
  105. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/stats/rate.py +0 -0
  106. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/stats/sampled_stat.py +0 -0
  107. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/stats/sensor.py +0 -0
  108. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/metrics/stats/total.py +0 -0
  109. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/oauth/__init__.py +0 -0
  110. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/oauth/abstract.py +0 -0
  111. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/partitioner/__init__.py +0 -0
  112. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/partitioner/default.py +0 -0
  113. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/producer/__init__.py +0 -0
  114. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/producer/buffer.py +0 -0
  115. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/abstract.py +0 -0
  116. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/commit.py +0 -0
  117. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/frame.py +0 -0
  118. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/group.py +0 -0
  119. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/metadata.py +0 -0
  120. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/pickle.py +0 -0
  121. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/protocol/struct.py +0 -0
  122. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/record/__init__.py +0 -0
  123. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/serializer/__init__.py +0 -0
  124. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/serializer/abstract.py +0 -0
  125. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/util.py +0 -0
  126. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka/vendor/enum34.py +0 -0
  127. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka_python.egg-info/dependency_links.txt +0 -0
  128. {kafka-python-2.0.1 → kafka-python-2.0.3}/kafka_python.egg-info/top_level.txt +0 -0
  129. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_acl_comparisons.py +0 -0
  130. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_admin.py +0 -0
  131. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_api_object_implementation.py +0 -0
  132. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_cluster.py +0 -0
  133. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_conn.py +0 -0
  134. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_consumer.py +0 -0
  135. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_consumer_group.py +0 -0
  136. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_metrics.py +0 -0
  137. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_object_conversion.py +0 -0
  138. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_package.py +0 -0
  139. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_partitioner.py +0 -0
  140. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_sasl_integration.py +0 -0
  141. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_sender.py +0 -0
  142. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/test_subscription_state.py +0 -0
  143. {kafka-python-2.0.1 → kafka-python-2.0.3}/test/testutil.py +0 -0
@@ -1,3 +1,97 @@
1
+ # 2.0.3 (Feb 12, 2025)
2
+
3
+ Improvements
4
+ * Add optional compression libs to extras_require (#2123, #2387)
5
+ * KafkaConsumer: Exit poll if consumer is closed (#2152)
6
+ * Support configuration of custom kafka client for Admin/Consumer/Producer (#2144)
7
+ * Core Protocol: Add support for flexible versions (#2151)
8
+ * (Internal) Allow disabling thread wakeup in _send_request_to_node (#2335)
9
+ * Change loglevel of cancelled errors to info (#2467)
10
+ * Strip trailing dot off hostname for SSL validation. (#2472)
11
+ * Log connection close(error) at ERROR level (#2473)
12
+ * Support DescribeLogDirs admin api (#2475)
13
+
14
+ Compatibility
15
+ * Support for python 3.12 (#2379, #2382)
16
+ * Kafka 2.5 / 2.6 (#2162)
17
+ * Try collections.abc imports in vendored selectors34 (#2394)
18
+ * Catch OSError when checking for gssapi import for windows compatibility (#2407)
19
+ * Update vendored six to 1.16.0 (#2398)
20
+
21
+ Documentation
22
+ * Update usage.rst (#2308, #2334)
23
+ * Fix typos (#2319, #2207, #2178)
24
+ * Fix links to the compatibility page (#2295, #2226)
25
+ * Cleanup install instructions for optional libs (#2139)
26
+ * Update license_file to license_files (#2462)
27
+ * Update some RST documentation syntax (#2463)
28
+ * Add .readthedocs.yaml; update copyright date (#2474)
29
+
30
+ Fixes
31
+ * Use isinstance in builtin crc32 (#2329)
32
+ * Use six.viewitems instead of six.iteritems to avoid encoding problems in StickyPartitionAssignor (#2154)
33
+ * Fix array encoding TypeError: object of type 'dict_itemiterator' has no len() (#2167)
34
+ * Only try to update sensors fetch lag if the unpacked list contains elements (#2158)
35
+ * Avoid logging errors during test fixture cleanup (#2458)
36
+ * Release coordinator lock before calling maybe_leave_group (#2460)
37
+ * Dont raise RuntimeError for dead process in SpawnedService.wait_for() (#2461)
38
+ * Cast the size of a MemoryRecordsBuilder object (#2438)
39
+ * Fix DescribeConfigsResponse_v1 config_source (#2464)
40
+ * Fix base class of DescribeClientQuotasResponse_v0 (#2465)
41
+ * Update socketpair w/ CVE-2024-3219 fix (#2468)
42
+
43
+ Testing
44
+ * Transition CI/CD to GitHub Workflows (#2378, #2392, #2381, #2406, #2419, #2418, #2417, #2456)
45
+ * Refactor Makefile (#2457)
46
+ * Use assert_called_with in client_async tests (#2375)
47
+ * Cover sticky assignor's metadata method with tests (#2161)
48
+ * Update fixtures.py to check "127.0.0.1" for auto port assignment (#2384)
49
+ * Use -Djava.security.manager=allow for Java 23 sasl tests (#2469)
50
+ * Test with Java 23 (#2470)
51
+ * Update kafka properties template; disable group rebalance delay (#2471)
52
+
53
+ # 2.0.2 (Sep 29, 2020)
54
+
55
+ Consumer
56
+ * KIP-54: Implement sticky partition assignment strategy (aynroot / PR #2057)
57
+ * Fix consumer deadlock when heartbeat thread request timeout (huangcuiyang / PR #2064)
58
+
59
+ Compatibility
60
+ * Python 3.8 support (Photonios / PR #2088)
61
+
62
+ Cleanups
63
+ * Bump dev requirements (jeffwidman / PR #2129)
64
+ * Fix crc32c deprecation warning (crc32c==2.1) (jeffwidman / PR #2128)
65
+ * Lint cleanup (jeffwidman / PR #2126)
66
+ * Fix initialization order in KafkaClient (pecalleja / PR #2119)
67
+ * Allow installing crc32c via extras (mishas / PR #2069)
68
+ * Remove unused imports (jameslamb / PR #2046)
69
+
70
+ Admin Client
71
+ * Merge _find_coordinator_id methods (jeffwidman / PR #2127)
72
+ * Feature: delete consumergroups (swenzel / PR #2040)
73
+ * Allow configurable timeouts in admin client check version (sunnyakaxd / PR #2107)
74
+ * Enhancement for Kafka Admin Client's "Describe Consumer Group" (Apurva007 / PR #2035)
75
+
76
+ Protocol
77
+ * Add support for zstd compression (gabriel-tincu / PR #2021)
78
+ * Add protocol support for brokers 1.1.0 - 2.5.0 (gabriel-tincu / PR #2038)
79
+ * Add ProduceRequest/ProduceResponse v6/v7/v8 (gabriel-tincu / PR #2020)
80
+ * Fix parsing NULL header values (kvfi / PR #2024)
81
+
82
+ Tests
83
+ * Add 2.5.0 to automated CI tests (gabriel-tincu / PR #2038)
84
+ * Add 2.1.1 to build_integration (gabriel-tincu / PR #2019)
85
+
86
+ Documentation / Logging / Errors
87
+ * Disable logging during producer object gc (gioele / PR #2043)
88
+ * Update example.py; use threading instead of multiprocessing (Mostafa-Elmenbawy / PR #2081)
89
+ * Fix typo in exception message (haracejacob / PR #2096)
90
+ * Add kafka.structs docstrings (Mostafa-Elmenbawy / PR #2080)
91
+ * Fix broken compatibility page link (anuragrana / PR #2045)
92
+ * Rename README to README.md (qhzxc0015 / PR #2055)
93
+ * Fix docs by adding SASL mention (jeffwidman / #1990)
94
+
1
95
  # 2.0.1 (Feb 19, 2020)
2
96
 
3
97
  Admin Client
@@ -0,0 +1,244 @@
1
+ Metadata-Version: 2.1
2
+ Name: kafka-python
3
+ Version: 2.0.3
4
+ Summary: Pure Python client for Apache Kafka
5
+ Home-page: https://github.com/dpkp/kafka-python
6
+ Author: Dana Powers
7
+ Author-email: dana.powers@gmail.com
8
+ License: Apache License 2.0
9
+ Description: Kafka Python client
10
+ ------------------------
11
+
12
+ .. image:: https://img.shields.io/badge/kafka-2.6%2C%202.5%2C%202.4%2C%202.3%2C%202.2%2C%202.1%2C%202.0%2C%201.1%2C%201.0%2C%200.11%2C%200.10%2C%200.9%2C%200.8-brightgreen.svg
13
+ :target: https://kafka-python.readthedocs.io/en/master/compatibility.html
14
+ .. image:: https://img.shields.io/pypi/pyversions/kafka-python.svg
15
+ :target: https://pypi.python.org/pypi/kafka-python
16
+ .. image:: https://coveralls.io/repos/dpkp/kafka-python/badge.svg?branch=master&service=github
17
+ :target: https://coveralls.io/github/dpkp/kafka-python?branch=master
18
+ .. image:: https://img.shields.io/badge/license-Apache%202-blue.svg
19
+ :target: https://github.com/dpkp/kafka-python/blob/master/LICENSE
20
+ .. image:: https://img.shields.io/pypi/dw/kafka-python.svg
21
+ :target: https://pypistats.org/packages/kafka-python
22
+ .. image:: https://img.shields.io/pypi/v/kafka-python.svg
23
+ :target: https://pypi.org/project/kafka-python
24
+ .. image:: https://img.shields.io/pypi/implementation/kafka-python
25
+ :target: https://github.com/dpkp/kafka-python/blob/master/setup.py
26
+
27
+
28
+
29
+ Python client for the Apache Kafka distributed stream processing system.
30
+ kafka-python is designed to function much like the official java client, with a
31
+ sprinkling of pythonic interfaces (e.g., consumer iterators).
32
+
33
+ kafka-python is best used with newer brokers (0.9+), but is backwards-compatible with
34
+ older versions (to 0.8.0). Some features will only be enabled on newer brokers.
35
+ For example, fully coordinated consumer groups -- i.e., dynamic partition
36
+ assignment to multiple consumers in the same group -- requires use of 0.9+ kafka
37
+ brokers. Supporting this feature for earlier broker releases would require
38
+ writing and maintaining custom leadership election and membership / health
39
+ check code (perhaps using zookeeper or consul). For older brokers, you can
40
+ achieve something similar by manually assigning different partitions to each
41
+ consumer instance with config management tools like chef, ansible, etc. This
42
+ approach will work fine, though it does not support rebalancing on failures.
43
+ See https://kafka-python.readthedocs.io/en/master/compatibility.html
44
+ for more details.
45
+
46
+ Please note that the master branch may contain unreleased features. For release
47
+ documentation, please see readthedocs and/or python's inline help.
48
+
49
+ .. code-block:: bash
50
+
51
+ $ pip install kafka-python
52
+
53
+
54
+ KafkaConsumer
55
+ *************
56
+
57
+ KafkaConsumer is a high-level message consumer, intended to operate as similarly
58
+ as possible to the official java client. Full support for coordinated
59
+ consumer groups requires use of kafka brokers that support the Group APIs: kafka v0.9+.
60
+
61
+ See https://kafka-python.readthedocs.io/en/master/apidoc/KafkaConsumer.html
62
+ for API and configuration details.
63
+
64
+ The consumer iterator returns ConsumerRecords, which are simple namedtuples
65
+ that expose basic message attributes: topic, partition, offset, key, and value:
66
+
67
+ .. code-block:: python
68
+
69
+ from kafka import KafkaConsumer
70
+ consumer = KafkaConsumer('my_favorite_topic')
71
+ for msg in consumer:
72
+ print (msg)
73
+
74
+ .. code-block:: python
75
+
76
+ # join a consumer group for dynamic partition assignment and offset commits
77
+ from kafka import KafkaConsumer
78
+ consumer = KafkaConsumer('my_favorite_topic', group_id='my_favorite_group')
79
+ for msg in consumer:
80
+ print (msg)
81
+
82
+ .. code-block:: python
83
+
84
+ # manually assign the partition list for the consumer
85
+ from kafka import TopicPartition
86
+ consumer = KafkaConsumer(bootstrap_servers='localhost:1234')
87
+ consumer.assign([TopicPartition('foobar', 2)])
88
+ msg = next(consumer)
89
+
90
+ .. code-block:: python
91
+
92
+ # Deserialize msgpack-encoded values
93
+ consumer = KafkaConsumer(value_deserializer=msgpack.loads)
94
+ consumer.subscribe(['msgpackfoo'])
95
+ for msg in consumer:
96
+ assert isinstance(msg.value, dict)
97
+
98
+ .. code-block:: python
99
+
100
+ # Access record headers. The returned value is a list of tuples
101
+ # with str, bytes for key and value
102
+ for msg in consumer:
103
+ print (msg.headers)
104
+
105
+ .. code-block:: python
106
+
107
+ # Get consumer metrics
108
+ metrics = consumer.metrics()
109
+
110
+
111
+ KafkaProducer
112
+ *************
113
+
114
+ KafkaProducer is a high-level, asynchronous message producer. The class is
115
+ intended to operate as similarly as possible to the official java client.
116
+ See https://kafka-python.readthedocs.io/en/master/apidoc/KafkaProducer.html
117
+ for more details.
118
+
119
+ .. code-block:: python
120
+
121
+ from kafka import KafkaProducer
122
+ producer = KafkaProducer(bootstrap_servers='localhost:1234')
123
+ for _ in range(100):
124
+ producer.send('foobar', b'some_message_bytes')
125
+
126
+ .. code-block:: python
127
+
128
+ # Block until a single message is sent (or timeout)
129
+ future = producer.send('foobar', b'another_message')
130
+ result = future.get(timeout=60)
131
+
132
+ .. code-block:: python
133
+
134
+ # Block until all pending messages are at least put on the network
135
+ # NOTE: This does not guarantee delivery or success! It is really
136
+ # only useful if you configure internal batching using linger_ms
137
+ producer.flush()
138
+
139
+ .. code-block:: python
140
+
141
+ # Use a key for hashed-partitioning
142
+ producer.send('foobar', key=b'foo', value=b'bar')
143
+
144
+ .. code-block:: python
145
+
146
+ # Serialize json messages
147
+ import json
148
+ producer = KafkaProducer(value_serializer=lambda v: json.dumps(v).encode('utf-8'))
149
+ producer.send('fizzbuzz', {'foo': 'bar'})
150
+
151
+ .. code-block:: python
152
+
153
+ # Serialize string keys
154
+ producer = KafkaProducer(key_serializer=str.encode)
155
+ producer.send('flipflap', key='ping', value=b'1234')
156
+
157
+ .. code-block:: python
158
+
159
+ # Compress messages
160
+ producer = KafkaProducer(compression_type='gzip')
161
+ for i in range(1000):
162
+ producer.send('foobar', b'msg %d' % i)
163
+
164
+ .. code-block:: python
165
+
166
+ # Include record headers. The format is list of tuples with string key
167
+ # and bytes value.
168
+ producer.send('foobar', value=b'c29tZSB2YWx1ZQ==', headers=[('content-encoding', b'base64')])
169
+
170
+ .. code-block:: python
171
+
172
+ # Get producer performance metrics
173
+ metrics = producer.metrics()
174
+
175
+
176
+ Thread safety
177
+ *************
178
+
179
+ The KafkaProducer can be used across threads without issue, unlike the
180
+ KafkaConsumer which cannot.
181
+
182
+ While it is possible to use the KafkaConsumer in a thread-local manner,
183
+ multiprocessing is recommended.
184
+
185
+
186
+ Compression
187
+ ***********
188
+
189
+ kafka-python supports the following compression formats:
190
+
191
+ - gzip
192
+ - LZ4
193
+ - Snappy
194
+ - Zstandard (zstd)
195
+
196
+ gzip is supported natively, the others require installing additional libraries.
197
+ See https://kafka-python.readthedocs.io/en/master/install.html for more information.
198
+
199
+
200
+ Optimized CRC32 Validation
201
+ **************************
202
+
203
+ Kafka uses CRC32 checksums to validate messages. kafka-python includes a pure
204
+ python implementation for compatibility. To improve performance for high-throughput
205
+ applications, kafka-python will use `crc32c` for optimized native code if installed.
206
+ See https://kafka-python.readthedocs.io/en/master/install.html for installation instructions.
207
+ See https://pypi.org/project/crc32c/ for details on the underlying crc32c lib.
208
+
209
+
210
+ Protocol
211
+ ********
212
+
213
+ A secondary goal of kafka-python is to provide an easy-to-use protocol layer
214
+ for interacting with kafka brokers via the python repl. This is useful for
215
+ testing, probing, and general experimentation. The protocol support is
216
+ leveraged to enable a KafkaClient.check_version() method that
217
+ probes a kafka broker and attempts to identify which version it is running
218
+ (0.8.0 to 2.6+).
219
+
220
+ Keywords: apache kafka,kafka
221
+ Platform: UNKNOWN
222
+ Classifier: Development Status :: 5 - Production/Stable
223
+ Classifier: Intended Audience :: Developers
224
+ Classifier: License :: OSI Approved :: Apache Software License
225
+ Classifier: Programming Language :: Python
226
+ Classifier: Programming Language :: Python :: 2
227
+ Classifier: Programming Language :: Python :: 2.7
228
+ Classifier: Programming Language :: Python :: 3
229
+ Classifier: Programming Language :: Python :: 3.4
230
+ Classifier: Programming Language :: Python :: 3.5
231
+ Classifier: Programming Language :: Python :: 3.6
232
+ Classifier: Programming Language :: Python :: 3.7
233
+ Classifier: Programming Language :: Python :: 3.8
234
+ Classifier: Programming Language :: Python :: 3.9
235
+ Classifier: Programming Language :: Python :: 3.10
236
+ Classifier: Programming Language :: Python :: 3.11
237
+ Classifier: Programming Language :: Python :: 3.12
238
+ Classifier: Programming Language :: Python :: Implementation :: CPython
239
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
240
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
241
+ Provides-Extra: zstd
242
+ Provides-Extra: crc32c
243
+ Provides-Extra: snappy
244
+ Provides-Extra: lz4
@@ -0,0 +1,210 @@
1
+ Kafka Python client
2
+ ------------------------
3
+
4
+ .. image:: https://img.shields.io/badge/kafka-2.6%2C%202.5%2C%202.4%2C%202.3%2C%202.2%2C%202.1%2C%202.0%2C%201.1%2C%201.0%2C%200.11%2C%200.10%2C%200.9%2C%200.8-brightgreen.svg
5
+ :target: https://kafka-python.readthedocs.io/en/master/compatibility.html
6
+ .. image:: https://img.shields.io/pypi/pyversions/kafka-python.svg
7
+ :target: https://pypi.python.org/pypi/kafka-python
8
+ .. image:: https://coveralls.io/repos/dpkp/kafka-python/badge.svg?branch=master&service=github
9
+ :target: https://coveralls.io/github/dpkp/kafka-python?branch=master
10
+ .. image:: https://img.shields.io/badge/license-Apache%202-blue.svg
11
+ :target: https://github.com/dpkp/kafka-python/blob/master/LICENSE
12
+ .. image:: https://img.shields.io/pypi/dw/kafka-python.svg
13
+ :target: https://pypistats.org/packages/kafka-python
14
+ .. image:: https://img.shields.io/pypi/v/kafka-python.svg
15
+ :target: https://pypi.org/project/kafka-python
16
+ .. image:: https://img.shields.io/pypi/implementation/kafka-python
17
+ :target: https://github.com/dpkp/kafka-python/blob/master/setup.py
18
+
19
+
20
+
21
+ Python client for the Apache Kafka distributed stream processing system.
22
+ kafka-python is designed to function much like the official java client, with a
23
+ sprinkling of pythonic interfaces (e.g., consumer iterators).
24
+
25
+ kafka-python is best used with newer brokers (0.9+), but is backwards-compatible with
26
+ older versions (to 0.8.0). Some features will only be enabled on newer brokers.
27
+ For example, fully coordinated consumer groups -- i.e., dynamic partition
28
+ assignment to multiple consumers in the same group -- requires use of 0.9+ kafka
29
+ brokers. Supporting this feature for earlier broker releases would require
30
+ writing and maintaining custom leadership election and membership / health
31
+ check code (perhaps using zookeeper or consul). For older brokers, you can
32
+ achieve something similar by manually assigning different partitions to each
33
+ consumer instance with config management tools like chef, ansible, etc. This
34
+ approach will work fine, though it does not support rebalancing on failures.
35
+ See https://kafka-python.readthedocs.io/en/master/compatibility.html
36
+ for more details.
37
+
38
+ Please note that the master branch may contain unreleased features. For release
39
+ documentation, please see readthedocs and/or python's inline help.
40
+
41
+ .. code-block:: bash
42
+
43
+ $ pip install kafka-python
44
+
45
+
46
+ KafkaConsumer
47
+ *************
48
+
49
+ KafkaConsumer is a high-level message consumer, intended to operate as similarly
50
+ as possible to the official java client. Full support for coordinated
51
+ consumer groups requires use of kafka brokers that support the Group APIs: kafka v0.9+.
52
+
53
+ See https://kafka-python.readthedocs.io/en/master/apidoc/KafkaConsumer.html
54
+ for API and configuration details.
55
+
56
+ The consumer iterator returns ConsumerRecords, which are simple namedtuples
57
+ that expose basic message attributes: topic, partition, offset, key, and value:
58
+
59
+ .. code-block:: python
60
+
61
+ from kafka import KafkaConsumer
62
+ consumer = KafkaConsumer('my_favorite_topic')
63
+ for msg in consumer:
64
+ print (msg)
65
+
66
+ .. code-block:: python
67
+
68
+ # join a consumer group for dynamic partition assignment and offset commits
69
+ from kafka import KafkaConsumer
70
+ consumer = KafkaConsumer('my_favorite_topic', group_id='my_favorite_group')
71
+ for msg in consumer:
72
+ print (msg)
73
+
74
+ .. code-block:: python
75
+
76
+ # manually assign the partition list for the consumer
77
+ from kafka import TopicPartition
78
+ consumer = KafkaConsumer(bootstrap_servers='localhost:1234')
79
+ consumer.assign([TopicPartition('foobar', 2)])
80
+ msg = next(consumer)
81
+
82
+ .. code-block:: python
83
+
84
+ # Deserialize msgpack-encoded values
85
+ consumer = KafkaConsumer(value_deserializer=msgpack.loads)
86
+ consumer.subscribe(['msgpackfoo'])
87
+ for msg in consumer:
88
+ assert isinstance(msg.value, dict)
89
+
90
+ .. code-block:: python
91
+
92
+ # Access record headers. The returned value is a list of tuples
93
+ # with str, bytes for key and value
94
+ for msg in consumer:
95
+ print (msg.headers)
96
+
97
+ .. code-block:: python
98
+
99
+ # Get consumer metrics
100
+ metrics = consumer.metrics()
101
+
102
+
103
+ KafkaProducer
104
+ *************
105
+
106
+ KafkaProducer is a high-level, asynchronous message producer. The class is
107
+ intended to operate as similarly as possible to the official java client.
108
+ See https://kafka-python.readthedocs.io/en/master/apidoc/KafkaProducer.html
109
+ for more details.
110
+
111
+ .. code-block:: python
112
+
113
+ from kafka import KafkaProducer
114
+ producer = KafkaProducer(bootstrap_servers='localhost:1234')
115
+ for _ in range(100):
116
+ producer.send('foobar', b'some_message_bytes')
117
+
118
+ .. code-block:: python
119
+
120
+ # Block until a single message is sent (or timeout)
121
+ future = producer.send('foobar', b'another_message')
122
+ result = future.get(timeout=60)
123
+
124
+ .. code-block:: python
125
+
126
+ # Block until all pending messages are at least put on the network
127
+ # NOTE: This does not guarantee delivery or success! It is really
128
+ # only useful if you configure internal batching using linger_ms
129
+ producer.flush()
130
+
131
+ .. code-block:: python
132
+
133
+ # Use a key for hashed-partitioning
134
+ producer.send('foobar', key=b'foo', value=b'bar')
135
+
136
+ .. code-block:: python
137
+
138
+ # Serialize json messages
139
+ import json
140
+ producer = KafkaProducer(value_serializer=lambda v: json.dumps(v).encode('utf-8'))
141
+ producer.send('fizzbuzz', {'foo': 'bar'})
142
+
143
+ .. code-block:: python
144
+
145
+ # Serialize string keys
146
+ producer = KafkaProducer(key_serializer=str.encode)
147
+ producer.send('flipflap', key='ping', value=b'1234')
148
+
149
+ .. code-block:: python
150
+
151
+ # Compress messages
152
+ producer = KafkaProducer(compression_type='gzip')
153
+ for i in range(1000):
154
+ producer.send('foobar', b'msg %d' % i)
155
+
156
+ .. code-block:: python
157
+
158
+ # Include record headers. The format is list of tuples with string key
159
+ # and bytes value.
160
+ producer.send('foobar', value=b'c29tZSB2YWx1ZQ==', headers=[('content-encoding', b'base64')])
161
+
162
+ .. code-block:: python
163
+
164
+ # Get producer performance metrics
165
+ metrics = producer.metrics()
166
+
167
+
168
+ Thread safety
169
+ *************
170
+
171
+ The KafkaProducer can be used across threads without issue, unlike the
172
+ KafkaConsumer which cannot.
173
+
174
+ While it is possible to use the KafkaConsumer in a thread-local manner,
175
+ multiprocessing is recommended.
176
+
177
+
178
+ Compression
179
+ ***********
180
+
181
+ kafka-python supports the following compression formats:
182
+
183
+ - gzip
184
+ - LZ4
185
+ - Snappy
186
+ - Zstandard (zstd)
187
+
188
+ gzip is supported natively, the others require installing additional libraries.
189
+ See https://kafka-python.readthedocs.io/en/master/install.html for more information.
190
+
191
+
192
+ Optimized CRC32 Validation
193
+ **************************
194
+
195
+ Kafka uses CRC32 checksums to validate messages. kafka-python includes a pure
196
+ python implementation for compatibility. To improve performance for high-throughput
197
+ applications, kafka-python will use `crc32c` for optimized native code if installed.
198
+ See https://kafka-python.readthedocs.io/en/master/install.html for installation instructions.
199
+ See https://pypi.org/project/crc32c/ for details on the underlying crc32c lib.
200
+
201
+
202
+ Protocol
203
+ ********
204
+
205
+ A secondary goal of kafka-python is to provide an easy-to-use protocol layer
206
+ for interacting with kafka brokers via the python repl. This is useful for
207
+ testing, probing, and general experimentation. The protocol support is
208
+ leveraged to enable a KafkaClient.check_version() method that
209
+ probes a kafka broker and attempts to identify which version it is running
210
+ (0.8.0 to 2.6+).
@@ -4,7 +4,7 @@ __title__ = 'kafka'
4
4
  from kafka.version import __version__
5
5
  __author__ = 'Dana Powers'
6
6
  __license__ = 'Apache License 2.0'
7
- __copyright__ = 'Copyright 2016 Dana Powers, David Arthur, and Contributors'
7
+ __copyright__ = 'Copyright 2025 Dana Powers, David Arthur, and Contributors'
8
8
 
9
9
  # Set default logging handler to avoid "No handler found" warnings.
10
10
  import logging