kafka-python 2.0.2__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 (139) hide show
  1. {kafka-python-2.0.2 → kafka-python-2.0.3}/CHANGES.md +52 -0
  2. {kafka-python-2.0.2 → kafka-python-2.0.3}/PKG-INFO +132 -75
  3. kafka-python-2.0.3/README.rst +210 -0
  4. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/__init__.py +1 -1
  5. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/admin/client.py +29 -8
  6. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/codec.py +1 -1
  7. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/conn.py +5 -4
  8. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/consumer/fetcher.py +12 -3
  9. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/consumer/group.py +7 -3
  10. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/coordinator/assignors/sticky/sticky_assignor.py +7 -3
  11. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/coordinator/base.py +6 -1
  12. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/producer/kafka.py +9 -6
  13. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/__init__.py +3 -0
  14. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/admin.py +173 -2
  15. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/api.py +42 -1
  16. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/parser.py +7 -14
  17. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/types.py +169 -2
  18. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/record/_crc32c.py +1 -1
  19. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/record/abc.py +1 -1
  20. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/record/legacy_records.py +1 -1
  21. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/vendor/selectors34.py +5 -1
  22. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/vendor/six.py +128 -21
  23. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/vendor/socketpair.py +17 -0
  24. kafka-python-2.0.3/kafka/version.py +1 -0
  25. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka_python.egg-info/PKG-INFO +132 -75
  26. kafka-python-2.0.3/kafka_python.egg-info/requires.txt +12 -0
  27. {kafka-python-2.0.2 → kafka-python-2.0.3}/setup.cfg +1 -1
  28. {kafka-python-2.0.2 → kafka-python-2.0.3}/setup.py +15 -2
  29. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_assignors.py +34 -43
  30. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_client_async.py +2 -2
  31. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_fetcher.py +18 -0
  32. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_protocol.py +53 -1
  33. kafka-python-2.0.2/README.rst +0 -161
  34. kafka-python-2.0.2/kafka/version.py +0 -1
  35. kafka-python-2.0.2/kafka_python.egg-info/requires.txt +0 -3
  36. {kafka-python-2.0.2 → kafka-python-2.0.3}/AUTHORS.md +0 -0
  37. {kafka-python-2.0.2 → kafka-python-2.0.3}/LICENSE +0 -0
  38. {kafka-python-2.0.2 → kafka-python-2.0.3}/MANIFEST.in +0 -0
  39. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/admin/__init__.py +0 -0
  40. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/admin/acl_resource.py +0 -0
  41. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/admin/config_resource.py +0 -0
  42. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/admin/new_partitions.py +0 -0
  43. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/admin/new_topic.py +0 -0
  44. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/client_async.py +0 -0
  45. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/cluster.py +0 -0
  46. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/consumer/__init__.py +0 -0
  47. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/consumer/subscription_state.py +0 -0
  48. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/coordinator/__init__.py +0 -0
  49. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/coordinator/assignors/__init__.py +0 -0
  50. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/coordinator/assignors/abstract.py +0 -0
  51. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/coordinator/assignors/range.py +0 -0
  52. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/coordinator/assignors/roundrobin.py +0 -0
  53. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/coordinator/assignors/sticky/__init__.py +0 -0
  54. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/coordinator/assignors/sticky/partition_movements.py +0 -0
  55. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/coordinator/assignors/sticky/sorted_set.py +0 -0
  56. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/coordinator/consumer.py +0 -0
  57. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/coordinator/heartbeat.py +0 -0
  58. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/coordinator/protocol.py +0 -0
  59. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/errors.py +0 -0
  60. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/future.py +0 -0
  61. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/__init__.py +0 -0
  62. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/compound_stat.py +0 -0
  63. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/dict_reporter.py +0 -0
  64. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/kafka_metric.py +0 -0
  65. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/measurable.py +0 -0
  66. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/measurable_stat.py +0 -0
  67. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/metric_config.py +0 -0
  68. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/metric_name.py +0 -0
  69. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/metrics.py +0 -0
  70. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/metrics_reporter.py +0 -0
  71. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/quota.py +0 -0
  72. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/stat.py +0 -0
  73. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/stats/__init__.py +0 -0
  74. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/stats/avg.py +0 -0
  75. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/stats/count.py +0 -0
  76. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/stats/histogram.py +0 -0
  77. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/stats/max_stat.py +0 -0
  78. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/stats/min_stat.py +0 -0
  79. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/stats/percentile.py +0 -0
  80. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/stats/percentiles.py +0 -0
  81. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/stats/rate.py +0 -0
  82. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/stats/sampled_stat.py +0 -0
  83. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/stats/sensor.py +0 -0
  84. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/metrics/stats/total.py +0 -0
  85. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/oauth/__init__.py +0 -0
  86. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/oauth/abstract.py +0 -0
  87. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/partitioner/__init__.py +0 -0
  88. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/partitioner/default.py +0 -0
  89. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/producer/__init__.py +0 -0
  90. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/producer/buffer.py +0 -0
  91. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/producer/future.py +0 -0
  92. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/producer/record_accumulator.py +0 -0
  93. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/producer/sender.py +0 -0
  94. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/abstract.py +0 -0
  95. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/commit.py +0 -0
  96. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/fetch.py +0 -0
  97. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/frame.py +0 -0
  98. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/group.py +0 -0
  99. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/message.py +0 -0
  100. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/metadata.py +0 -0
  101. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/offset.py +0 -0
  102. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/pickle.py +0 -0
  103. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/produce.py +0 -0
  104. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/protocol/struct.py +0 -0
  105. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/record/__init__.py +0 -0
  106. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/record/default_records.py +0 -0
  107. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/record/memory_records.py +0 -0
  108. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/record/util.py +0 -0
  109. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/scram.py +0 -0
  110. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/serializer/__init__.py +0 -0
  111. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/serializer/abstract.py +0 -0
  112. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/structs.py +0 -0
  113. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/util.py +0 -0
  114. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/vendor/__init__.py +0 -0
  115. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka/vendor/enum34.py +0 -0
  116. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka_python.egg-info/SOURCES.txt +0 -0
  117. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka_python.egg-info/dependency_links.txt +0 -0
  118. {kafka-python-2.0.2 → kafka-python-2.0.3}/kafka_python.egg-info/top_level.txt +0 -0
  119. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_acl_comparisons.py +0 -0
  120. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_admin.py +0 -0
  121. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_admin_integration.py +0 -0
  122. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_api_object_implementation.py +0 -0
  123. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_cluster.py +0 -0
  124. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_codec.py +0 -0
  125. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_conn.py +0 -0
  126. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_consumer.py +0 -0
  127. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_consumer_group.py +0 -0
  128. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_consumer_integration.py +0 -0
  129. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_coordinator.py +0 -0
  130. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_metrics.py +0 -0
  131. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_object_conversion.py +0 -0
  132. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_package.py +0 -0
  133. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_partition_movements.py +0 -0
  134. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_partitioner.py +0 -0
  135. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_producer.py +0 -0
  136. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_sasl_integration.py +0 -0
  137. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_sender.py +0 -0
  138. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/test_subscription_state.py +0 -0
  139. {kafka-python-2.0.2 → kafka-python-2.0.3}/test/testutil.py +0 -0
@@ -1,3 +1,55 @@
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
+
1
53
  # 2.0.2 (Sep 29, 2020)
2
54
 
3
55
  Consumer
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kafka-python
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: Pure Python client for Apache Kafka
5
5
  Home-page: https://github.com/dpkp/kafka-python
6
6
  Author: Dana Powers
@@ -9,16 +9,22 @@ License: Apache License 2.0
9
9
  Description: Kafka Python client
10
10
  ------------------------
11
11
 
12
- .. image:: https://img.shields.io/badge/kafka-2.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
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
13
  :target: https://kafka-python.readthedocs.io/en/master/compatibility.html
14
14
  .. image:: https://img.shields.io/pypi/pyversions/kafka-python.svg
15
15
  :target: https://pypi.python.org/pypi/kafka-python
16
16
  .. image:: https://coveralls.io/repos/dpkp/kafka-python/badge.svg?branch=master&service=github
17
17
  :target: https://coveralls.io/github/dpkp/kafka-python?branch=master
18
- .. image:: https://travis-ci.org/dpkp/kafka-python.svg?branch=master
19
- :target: https://travis-ci.org/dpkp/kafka-python
20
18
  .. image:: https://img.shields.io/badge/license-Apache%202-blue.svg
21
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
+
22
28
 
23
29
  Python client for the Apache Kafka distributed stream processing system.
24
30
  kafka-python is designed to function much like the official java client, with a
@@ -34,13 +40,16 @@ Description: Kafka Python client
34
40
  achieve something similar by manually assigning different partitions to each
35
41
  consumer instance with config management tools like chef, ansible, etc. This
36
42
  approach will work fine, though it does not support rebalancing on failures.
37
- See <https://kafka-python.readthedocs.io/en/master/compatibility.html>
43
+ See https://kafka-python.readthedocs.io/en/master/compatibility.html
38
44
  for more details.
39
45
 
40
46
  Please note that the master branch may contain unreleased features. For release
41
47
  documentation, please see readthedocs and/or python's inline help.
42
48
 
43
- >>> pip install kafka-python
49
+ .. code-block:: bash
50
+
51
+ $ pip install kafka-python
52
+
44
53
 
45
54
  KafkaConsumer
46
55
  *************
@@ -49,88 +58,120 @@ Description: Kafka Python client
49
58
  as possible to the official java client. Full support for coordinated
50
59
  consumer groups requires use of kafka brokers that support the Group APIs: kafka v0.9+.
51
60
 
52
- See <https://kafka-python.readthedocs.io/en/master/apidoc/KafkaConsumer.html>
61
+ See https://kafka-python.readthedocs.io/en/master/apidoc/KafkaConsumer.html
53
62
  for API and configuration details.
54
63
 
55
64
  The consumer iterator returns ConsumerRecords, which are simple namedtuples
56
65
  that expose basic message attributes: topic, partition, offset, key, and value:
57
66
 
58
- >>> from kafka import KafkaConsumer
59
- >>> consumer = KafkaConsumer('my_favorite_topic')
60
- >>> for msg in consumer:
61
- ... print (msg)
62
-
63
- >>> # join a consumer group for dynamic partition assignment and offset commits
64
- >>> from kafka import KafkaConsumer
65
- >>> consumer = KafkaConsumer('my_favorite_topic', group_id='my_favorite_group')
66
- >>> for msg in consumer:
67
- ... print (msg)
68
-
69
- >>> # manually assign the partition list for the consumer
70
- >>> from kafka import TopicPartition
71
- >>> consumer = KafkaConsumer(bootstrap_servers='localhost:1234')
72
- >>> consumer.assign([TopicPartition('foobar', 2)])
73
- >>> msg = next(consumer)
74
-
75
- >>> # Deserialize msgpack-encoded values
76
- >>> consumer = KafkaConsumer(value_deserializer=msgpack.loads)
77
- >>> consumer.subscribe(['msgpackfoo'])
78
- >>> for msg in consumer:
79
- ... assert isinstance(msg.value, dict)
80
-
81
- >>> # Access record headers. The returned value is a list of tuples
82
- >>> # with str, bytes for key and value
83
- >>> for msg in consumer:
84
- ... print (msg.headers)
85
-
86
- >>> # Get consumer metrics
87
- >>> metrics = consumer.metrics()
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
+
88
110
 
89
111
  KafkaProducer
90
112
  *************
91
113
 
92
114
  KafkaProducer is a high-level, asynchronous message producer. The class is
93
115
  intended to operate as similarly as possible to the official java client.
94
- See <https://kafka-python.readthedocs.io/en/master/apidoc/KafkaProducer.html>
116
+ See https://kafka-python.readthedocs.io/en/master/apidoc/KafkaProducer.html
95
117
  for more details.
96
118
 
97
- >>> from kafka import KafkaProducer
98
- >>> producer = KafkaProducer(bootstrap_servers='localhost:1234')
99
- >>> for _ in range(100):
100
- ... producer.send('foobar', b'some_message_bytes')
119
+ .. code-block:: python
101
120
 
102
- >>> # Block until a single message is sent (or timeout)
103
- >>> future = producer.send('foobar', b'another_message')
104
- >>> result = future.get(timeout=60)
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')
105
125
 
106
- >>> # Block until all pending messages are at least put on the network
107
- >>> # NOTE: This does not guarantee delivery or success! It is really
108
- >>> # only useful if you configure internal batching using linger_ms
109
- >>> producer.flush()
126
+ .. code-block:: python
110
127
 
111
- >>> # Use a key for hashed-partitioning
112
- >>> producer.send('foobar', key=b'foo', value=b'bar')
128
+ # Block until a single message is sent (or timeout)
129
+ future = producer.send('foobar', b'another_message')
130
+ result = future.get(timeout=60)
113
131
 
114
- >>> # Serialize json messages
115
- >>> import json
116
- >>> producer = KafkaProducer(value_serializer=lambda v: json.dumps(v).encode('utf-8'))
117
- >>> producer.send('fizzbuzz', {'foo': 'bar'})
132
+ .. code-block:: python
118
133
 
119
- >>> # Serialize string keys
120
- >>> producer = KafkaProducer(key_serializer=str.encode)
121
- >>> producer.send('flipflap', key='ping', value=b'1234')
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()
122
138
 
123
- >>> # Compress messages
124
- >>> producer = KafkaProducer(compression_type='gzip')
125
- >>> for i in range(1000):
126
- ... producer.send('foobar', b'msg %d' % i)
139
+ .. code-block:: python
127
140
 
128
- >>> # Include record headers. The format is list of tuples with string key
129
- >>> # and bytes value.
130
- >>> producer.send('foobar', value=b'c29tZSB2YWx1ZQ==', headers=[('content-encoding', b'base64')])
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()
131
174
 
132
- >>> # Get producer performance metrics
133
- >>> metrics = producer.metrics()
134
175
 
135
176
  Thread safety
136
177
  *************
@@ -141,14 +182,20 @@ Description: Kafka Python client
141
182
  While it is possible to use the KafkaConsumer in a thread-local manner,
142
183
  multiprocessing is recommended.
143
184
 
185
+
144
186
  Compression
145
187
  ***********
146
188
 
147
- kafka-python supports gzip compression/decompression natively. To produce or consume lz4
148
- compressed messages, you should install python-lz4 (pip install lz4).
149
- To enable snappy compression/decompression install python-snappy (also requires snappy library).
150
- See <https://kafka-python.readthedocs.io/en/master/install.html#optional-snappy-install>
151
- for more information.
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
+
152
199
 
153
200
  Optimized CRC32 Validation
154
201
  **************************
@@ -156,7 +203,9 @@ Description: Kafka Python client
156
203
  Kafka uses CRC32 checksums to validate messages. kafka-python includes a pure
157
204
  python implementation for compatibility. To improve performance for high-throughput
158
205
  applications, kafka-python will use `crc32c` for optimized native code if installed.
159
- See https://pypi.org/project/crc32c/
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
+
160
209
 
161
210
  Protocol
162
211
  ********
@@ -166,9 +215,9 @@ Description: Kafka Python client
166
215
  testing, probing, and general experimentation. The protocol support is
167
216
  leveraged to enable a KafkaClient.check_version() method that
168
217
  probes a kafka broker and attempts to identify which version it is running
169
- (0.8.0 to 2.4+).
218
+ (0.8.0 to 2.6+).
170
219
 
171
- Keywords: apache kafka
220
+ Keywords: apache kafka,kafka
172
221
  Platform: UNKNOWN
173
222
  Classifier: Development Status :: 5 - Production/Stable
174
223
  Classifier: Intended Audience :: Developers
@@ -182,6 +231,14 @@ Classifier: Programming Language :: Python :: 3.5
182
231
  Classifier: Programming Language :: Python :: 3.6
183
232
  Classifier: Programming Language :: Python :: 3.7
184
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
185
239
  Classifier: Programming Language :: Python :: Implementation :: PyPy
186
240
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
241
+ Provides-Extra: zstd
187
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