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