kafka-python 3.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kafka/__init__.py +34 -0
- kafka/__main__.py +5 -0
- kafka/admin/__init__.py +29 -0
- kafka/admin/__main__.py +5 -0
- kafka/admin/_acls.py +355 -0
- kafka/admin/_cluster.py +359 -0
- kafka/admin/_configs.py +479 -0
- kafka/admin/_groups.py +754 -0
- kafka/admin/_partitions.py +595 -0
- kafka/admin/_topics.py +281 -0
- kafka/admin/_transactions.py +450 -0
- kafka/admin/_users.py +194 -0
- kafka/admin/client.py +373 -0
- kafka/benchmarks/__init__.py +0 -0
- kafka/benchmarks/consumer_performance.py +138 -0
- kafka/benchmarks/load_example.py +109 -0
- kafka/benchmarks/producer_encode_path.py +201 -0
- kafka/benchmarks/producer_performance.py +161 -0
- kafka/benchmarks/profile_protocol.py +138 -0
- kafka/benchmarks/protocol_old_vs_new.py +447 -0
- kafka/benchmarks/record_batch_compose.py +77 -0
- kafka/benchmarks/record_batch_read.py +82 -0
- kafka/benchmarks/varint_speed.py +426 -0
- kafka/cli/__init__.py +36 -0
- kafka/cli/admin/__init__.py +117 -0
- kafka/cli/admin/acls/__init__.py +9 -0
- kafka/cli/admin/acls/common.py +76 -0
- kafka/cli/admin/acls/create.py +19 -0
- kafka/cli/admin/acls/delete.py +23 -0
- kafka/cli/admin/acls/describe.py +16 -0
- kafka/cli/admin/cluster/__init__.py +14 -0
- kafka/cli/admin/cluster/describe.py +11 -0
- kafka/cli/admin/cluster/describe_quorum.py +11 -0
- kafka/cli/admin/cluster/features.py +52 -0
- kafka/cli/admin/cluster/log_dirs.py +43 -0
- kafka/cli/admin/cluster/versions.py +33 -0
- kafka/cli/admin/configs/__init__.py +10 -0
- kafka/cli/admin/configs/alter.py +43 -0
- kafka/cli/admin/configs/common.py +17 -0
- kafka/cli/admin/configs/describe.py +30 -0
- kafka/cli/admin/configs/list.py +16 -0
- kafka/cli/admin/configs/reset.py +20 -0
- kafka/cli/admin/groups/__init__.py +16 -0
- kafka/cli/admin/groups/alter_offsets.py +30 -0
- kafka/cli/admin/groups/delete.py +11 -0
- kafka/cli/admin/groups/delete_offsets.py +29 -0
- kafka/cli/admin/groups/describe.py +11 -0
- kafka/cli/admin/groups/list.py +28 -0
- kafka/cli/admin/groups/list_offsets.py +29 -0
- kafka/cli/admin/groups/remove_members.py +40 -0
- kafka/cli/admin/groups/reset_offsets.py +139 -0
- kafka/cli/admin/partitions/__init__.py +21 -0
- kafka/cli/admin/partitions/alter_reassignments.py +37 -0
- kafka/cli/admin/partitions/create.py +27 -0
- kafka/cli/admin/partitions/delete_records.py +31 -0
- kafka/cli/admin/partitions/describe.py +36 -0
- kafka/cli/admin/partitions/elect_leaders.py +53 -0
- kafka/cli/admin/partitions/list_offsets.py +88 -0
- kafka/cli/admin/partitions/list_reassignments.py +35 -0
- kafka/cli/admin/topics/__init__.py +10 -0
- kafka/cli/admin/topics/create.py +13 -0
- kafka/cli/admin/topics/delete.py +19 -0
- kafka/cli/admin/topics/describe.py +18 -0
- kafka/cli/admin/topics/list.py +11 -0
- kafka/cli/admin/transactions/__init__.py +17 -0
- kafka/cli/admin/transactions/abort.py +38 -0
- kafka/cli/admin/transactions/describe.py +24 -0
- kafka/cli/admin/transactions/describe_producers.py +29 -0
- kafka/cli/admin/transactions/find_hanging.py +26 -0
- kafka/cli/admin/transactions/list.py +37 -0
- kafka/cli/admin/users/__init__.py +8 -0
- kafka/cli/admin/users/alter_user_scram_credentials.py +34 -0
- kafka/cli/admin/users/describe_user_scram_credentials.py +15 -0
- kafka/cli/common.py +95 -0
- kafka/cli/consumer/__init__.py +63 -0
- kafka/cli/producer/__init__.py +57 -0
- kafka/cluster.py +824 -0
- kafka/codec.py +325 -0
- kafka/consumer/__init__.py +5 -0
- kafka/consumer/__main__.py +5 -0
- kafka/consumer/fetcher.py +2012 -0
- kafka/consumer/group.py +1347 -0
- kafka/consumer/subscription_state.py +897 -0
- kafka/coordinator/__init__.py +0 -0
- kafka/coordinator/assignors/__init__.py +0 -0
- kafka/coordinator/assignors/abstract.py +90 -0
- kafka/coordinator/assignors/cooperative_sticky.py +167 -0
- kafka/coordinator/assignors/range.py +81 -0
- kafka/coordinator/assignors/roundrobin.py +101 -0
- kafka/coordinator/assignors/sticky/StickyAssignorUserData.json +37 -0
- kafka/coordinator/assignors/sticky/__init__.py +0 -0
- kafka/coordinator/assignors/sticky/partition_movements.py +149 -0
- kafka/coordinator/assignors/sticky/sorted_set.py +63 -0
- kafka/coordinator/assignors/sticky/sticky_assignor.py +665 -0
- kafka/coordinator/assignors/sticky/user_data.py +8 -0
- kafka/coordinator/base.py +1215 -0
- kafka/coordinator/consumer.py +1224 -0
- kafka/coordinator/heartbeat.py +82 -0
- kafka/coordinator/subscription.py +34 -0
- kafka/errors.py +1004 -0
- kafka/future.py +166 -0
- kafka/metrics/__init__.py +13 -0
- kafka/metrics/compound_stat.py +33 -0
- kafka/metrics/dict_reporter.py +81 -0
- kafka/metrics/kafka_metric.py +36 -0
- kafka/metrics/measurable.py +27 -0
- kafka/metrics/measurable_stat.py +13 -0
- kafka/metrics/metric_config.py +33 -0
- kafka/metrics/metric_name.py +105 -0
- kafka/metrics/metrics.py +261 -0
- kafka/metrics/metrics_reporter.py +53 -0
- kafka/metrics/quota.py +41 -0
- kafka/metrics/stat.py +19 -0
- kafka/metrics/stats/__init__.py +15 -0
- kafka/metrics/stats/avg.py +24 -0
- kafka/metrics/stats/count.py +17 -0
- kafka/metrics/stats/histogram.py +99 -0
- kafka/metrics/stats/max_stat.py +17 -0
- kafka/metrics/stats/min_stat.py +19 -0
- kafka/metrics/stats/percentile.py +14 -0
- kafka/metrics/stats/percentiles.py +75 -0
- kafka/metrics/stats/rate.py +118 -0
- kafka/metrics/stats/sampled_stat.py +99 -0
- kafka/metrics/stats/sensor.py +136 -0
- kafka/metrics/stats/total.py +15 -0
- kafka/net/__init__.py +19 -0
- kafka/net/compat.py +165 -0
- kafka/net/connection.py +593 -0
- kafka/net/http_connect.py +144 -0
- kafka/net/inet.py +122 -0
- kafka/net/manager.py +451 -0
- kafka/net/metrics.py +149 -0
- kafka/net/sasl/__init__.py +32 -0
- kafka/net/sasl/abc.py +28 -0
- kafka/net/sasl/gssapi.py +95 -0
- kafka/net/sasl/msk.py +245 -0
- kafka/net/sasl/oauth.py +98 -0
- kafka/net/sasl/plain.py +42 -0
- kafka/net/sasl/scram.py +135 -0
- kafka/net/sasl/sspi.py +111 -0
- kafka/net/selector.py +644 -0
- kafka/net/socks5.py +262 -0
- kafka/net/transport.py +415 -0
- kafka/net/wakeup_notifier.py +72 -0
- kafka/partitioner/__init__.py +8 -0
- kafka/partitioner/abc.py +8 -0
- kafka/partitioner/default.py +89 -0
- kafka/partitioner/sticky.py +109 -0
- kafka/producer/__init__.py +5 -0
- kafka/producer/__main__.py +5 -0
- kafka/producer/future.py +101 -0
- kafka/producer/kafka.py +1123 -0
- kafka/producer/producer_batch.py +192 -0
- kafka/producer/record_accumulator.py +647 -0
- kafka/producer/sender.py +884 -0
- kafka/producer/transaction_manager.py +1326 -0
- kafka/protocol/__init__.py +0 -0
- kafka/protocol/admin/__init__.py +29 -0
- kafka/protocol/admin/acl.py +83 -0
- kafka/protocol/admin/acl.pyi +375 -0
- kafka/protocol/admin/client_quotas.py +14 -0
- kafka/protocol/admin/client_quotas.pyi +265 -0
- kafka/protocol/admin/cluster.py +31 -0
- kafka/protocol/admin/cluster.pyi +620 -0
- kafka/protocol/admin/configs.py +22 -0
- kafka/protocol/admin/configs.pyi +437 -0
- kafka/protocol/admin/groups.py +24 -0
- kafka/protocol/admin/groups.pyi +261 -0
- kafka/protocol/admin/topics.py +53 -0
- kafka/protocol/admin/topics.pyi +982 -0
- kafka/protocol/admin/transactions.py +18 -0
- kafka/protocol/admin/transactions.pyi +311 -0
- kafka/protocol/admin/users.py +14 -0
- kafka/protocol/admin/users.pyi +223 -0
- kafka/protocol/api_data.py +125 -0
- kafka/protocol/api_header.py +55 -0
- kafka/protocol/api_key.py +97 -0
- kafka/protocol/api_message.py +277 -0
- kafka/protocol/broker_version_data.py +246 -0
- kafka/protocol/consumer/__init__.py +13 -0
- kafka/protocol/consumer/fetch.py +16 -0
- kafka/protocol/consumer/fetch.pyi +298 -0
- kafka/protocol/consumer/group.py +38 -0
- kafka/protocol/consumer/group.pyi +824 -0
- kafka/protocol/consumer/metadata.py +30 -0
- kafka/protocol/consumer/metadata.pyi +89 -0
- kafka/protocol/consumer/offsets.py +75 -0
- kafka/protocol/consumer/offsets.pyi +288 -0
- kafka/protocol/data_container.py +166 -0
- kafka/protocol/frame.py +30 -0
- kafka/protocol/generate_stubs.py +468 -0
- kafka/protocol/metadata/__init__.py +10 -0
- kafka/protocol/metadata/api_versions.py +41 -0
- kafka/protocol/metadata/api_versions.pyi +128 -0
- kafka/protocol/metadata/find_coordinator.py +19 -0
- kafka/protocol/metadata/find_coordinator.pyi +105 -0
- kafka/protocol/metadata/metadata.py +34 -0
- kafka/protocol/metadata/metadata.pyi +160 -0
- kafka/protocol/old/__init__.py +0 -0
- kafka/protocol/old/abstract.py +17 -0
- kafka/protocol/old/add_offsets_to_txn.py +54 -0
- kafka/protocol/old/add_partitions_to_txn.py +71 -0
- kafka/protocol/old/admin.py +1086 -0
- kafka/protocol/old/api.py +205 -0
- kafka/protocol/old/api_versions.py +133 -0
- kafka/protocol/old/commit.py +355 -0
- kafka/protocol/old/consumer_protocol.py +36 -0
- kafka/protocol/old/end_txn.py +53 -0
- kafka/protocol/old/fetch.py +408 -0
- kafka/protocol/old/find_coordinator.py +72 -0
- kafka/protocol/old/group.py +451 -0
- kafka/protocol/old/init_producer_id.py +42 -0
- kafka/protocol/old/list_offsets.py +186 -0
- kafka/protocol/old/metadata.py +290 -0
- kafka/protocol/old/offset_for_leader_epoch.py +133 -0
- kafka/protocol/old/produce.py +247 -0
- kafka/protocol/old/sasl_authenticate.py +38 -0
- kafka/protocol/old/sasl_handshake.py +39 -0
- kafka/protocol/old/struct.py +87 -0
- kafka/protocol/old/txn_offset_commit.py +73 -0
- kafka/protocol/old/types.py +440 -0
- kafka/protocol/parser.py +191 -0
- kafka/protocol/producer/__init__.py +7 -0
- kafka/protocol/producer/produce.py +17 -0
- kafka/protocol/producer/produce.pyi +197 -0
- kafka/protocol/producer/transaction.py +30 -0
- kafka/protocol/producer/transaction.pyi +663 -0
- kafka/protocol/sasl.py +52 -0
- kafka/protocol/sasl.pyi +126 -0
- kafka/protocol/schemas/__init__.py +7 -0
- kafka/protocol/schemas/fields/__init__.py +7 -0
- kafka/protocol/schemas/fields/array.py +127 -0
- kafka/protocol/schemas/fields/base.py +156 -0
- kafka/protocol/schemas/fields/codecs/__init__.py +12 -0
- kafka/protocol/schemas/fields/codecs/encode_buffer.py +82 -0
- kafka/protocol/schemas/fields/codecs/tagged_fields.py +109 -0
- kafka/protocol/schemas/fields/codecs/types.py +505 -0
- kafka/protocol/schemas/fields/codegen.py +40 -0
- kafka/protocol/schemas/fields/simple.py +127 -0
- kafka/protocol/schemas/fields/struct.py +357 -0
- kafka/protocol/schemas/fields/struct_array.py +142 -0
- kafka/protocol/schemas/load_json.py +42 -0
- kafka/protocol/schemas/resources/AddOffsetsToTxnRequest.json +40 -0
- kafka/protocol/schemas/resources/AddOffsetsToTxnResponse.json +35 -0
- kafka/protocol/schemas/resources/AddPartitionsToTxnRequest.json +65 -0
- kafka/protocol/schemas/resources/AddPartitionsToTxnResponse.json +60 -0
- kafka/protocol/schemas/resources/AlterClientQuotasRequest.json +47 -0
- kafka/protocol/schemas/resources/AlterClientQuotasResponse.json +41 -0
- kafka/protocol/schemas/resources/AlterConfigsRequest.json +43 -0
- kafka/protocol/schemas/resources/AlterConfigsResponse.json +39 -0
- kafka/protocol/schemas/resources/AlterPartitionReassignmentsRequest.json +42 -0
- kafka/protocol/schemas/resources/AlterPartitionReassignmentsResponse.json +47 -0
- kafka/protocol/schemas/resources/AlterReplicaLogDirsRequest.json +41 -0
- kafka/protocol/schemas/resources/AlterReplicaLogDirsResponse.json +41 -0
- kafka/protocol/schemas/resources/AlterUserScramCredentialsRequest.json +45 -0
- kafka/protocol/schemas/resources/AlterUserScramCredentialsResponse.json +35 -0
- kafka/protocol/schemas/resources/ApiVersionsRequest.json +34 -0
- kafka/protocol/schemas/resources/ApiVersionsResponse.json +79 -0
- kafka/protocol/schemas/resources/ConsumerProtocolAssignment.json +42 -0
- kafka/protocol/schemas/resources/ConsumerProtocolSubscription.json +49 -0
- kafka/protocol/schemas/resources/CreateAclsRequest.json +46 -0
- kafka/protocol/schemas/resources/CreateAclsResponse.json +37 -0
- kafka/protocol/schemas/resources/CreatePartitionsRequest.json +47 -0
- kafka/protocol/schemas/resources/CreatePartitionsResponse.json +41 -0
- kafka/protocol/schemas/resources/CreateTopicsRequest.json +65 -0
- kafka/protocol/schemas/resources/CreateTopicsResponse.json +72 -0
- kafka/protocol/schemas/resources/DeleteAclsRequest.json +46 -0
- kafka/protocol/schemas/resources/DeleteAclsResponse.json +59 -0
- kafka/protocol/schemas/resources/DeleteGroupsRequest.json +30 -0
- kafka/protocol/schemas/resources/DeleteGroupsResponse.json +36 -0
- kafka/protocol/schemas/resources/DeleteRecordsRequest.json +42 -0
- kafka/protocol/schemas/resources/DeleteRecordsResponse.json +43 -0
- kafka/protocol/schemas/resources/DeleteTopicsRequest.json +43 -0
- kafka/protocol/schemas/resources/DeleteTopicsResponse.json +52 -0
- kafka/protocol/schemas/resources/DescribeAclsRequest.json +43 -0
- kafka/protocol/schemas/resources/DescribeAclsResponse.json +55 -0
- kafka/protocol/schemas/resources/DescribeClientQuotasRequest.json +37 -0
- kafka/protocol/schemas/resources/DescribeClientQuotasResponse.json +47 -0
- kafka/protocol/schemas/resources/DescribeClusterRequest.json +35 -0
- kafka/protocol/schemas/resources/DescribeClusterResponse.json +56 -0
- kafka/protocol/schemas/resources/DescribeConfigsRequest.json +42 -0
- kafka/protocol/schemas/resources/DescribeConfigsResponse.json +69 -0
- kafka/protocol/schemas/resources/DescribeGroupsRequest.json +38 -0
- kafka/protocol/schemas/resources/DescribeGroupsResponse.json +74 -0
- kafka/protocol/schemas/resources/DescribeLogDirsRequest.json +38 -0
- kafka/protocol/schemas/resources/DescribeLogDirsResponse.json +65 -0
- kafka/protocol/schemas/resources/DescribeProducersRequest.json +32 -0
- kafka/protocol/schemas/resources/DescribeProducersResponse.json +55 -0
- kafka/protocol/schemas/resources/DescribeQuorumRequest.json +39 -0
- kafka/protocol/schemas/resources/DescribeQuorumResponse.json +82 -0
- kafka/protocol/schemas/resources/DescribeTopicPartitionsRequest.json +40 -0
- kafka/protocol/schemas/resources/DescribeTopicPartitionsResponse.json +66 -0
- kafka/protocol/schemas/resources/DescribeTransactionsRequest.json +27 -0
- kafka/protocol/schemas/resources/DescribeTransactionsResponse.json +52 -0
- kafka/protocol/schemas/resources/DescribeUserScramCredentialsRequest.json +30 -0
- kafka/protocol/schemas/resources/DescribeUserScramCredentialsResponse.json +45 -0
- kafka/protocol/schemas/resources/ElectLeadersRequest.json +41 -0
- kafka/protocol/schemas/resources/ElectLeadersResponse.json +45 -0
- kafka/protocol/schemas/resources/EndTxnRequest.json +43 -0
- kafka/protocol/schemas/resources/EndTxnResponse.json +41 -0
- kafka/protocol/schemas/resources/FetchRequest.json +125 -0
- kafka/protocol/schemas/resources/FetchResponse.json +124 -0
- kafka/protocol/schemas/resources/FindCoordinatorRequest.json +43 -0
- kafka/protocol/schemas/resources/FindCoordinatorResponse.json +58 -0
- kafka/protocol/schemas/resources/HeartbeatRequest.json +39 -0
- kafka/protocol/schemas/resources/HeartbeatResponse.json +35 -0
- kafka/protocol/schemas/resources/IncrementalAlterConfigsRequest.json +44 -0
- kafka/protocol/schemas/resources/IncrementalAlterConfigsResponse.json +38 -0
- kafka/protocol/schemas/resources/InitProducerIdRequest.json +50 -0
- kafka/protocol/schemas/resources/InitProducerIdResponse.json +47 -0
- kafka/protocol/schemas/resources/JoinGroupRequest.json +63 -0
- kafka/protocol/schemas/resources/JoinGroupResponse.json +69 -0
- kafka/protocol/schemas/resources/LeaveGroupRequest.json +47 -0
- kafka/protocol/schemas/resources/LeaveGroupResponse.json +47 -0
- kafka/protocol/schemas/resources/ListConfigResourcesRequest.json +31 -0
- kafka/protocol/schemas/resources/ListConfigResourcesResponse.json +37 -0
- kafka/protocol/schemas/resources/ListGroupsRequest.json +36 -0
- kafka/protocol/schemas/resources/ListGroupsResponse.json +49 -0
- kafka/protocol/schemas/resources/ListOffsetsRequest.json +72 -0
- kafka/protocol/schemas/resources/ListOffsetsResponse.json +71 -0
- kafka/protocol/schemas/resources/ListPartitionReassignmentsRequest.json +34 -0
- kafka/protocol/schemas/resources/ListPartitionReassignmentsResponse.json +46 -0
- kafka/protocol/schemas/resources/ListTransactionsRequest.json +40 -0
- kafka/protocol/schemas/resources/ListTransactionsResponse.json +42 -0
- kafka/protocol/schemas/resources/MetadataRequest.json +56 -0
- kafka/protocol/schemas/resources/MetadataResponse.json +101 -0
- kafka/protocol/schemas/resources/OffsetCommitRequest.json +76 -0
- kafka/protocol/schemas/resources/OffsetCommitResponse.json +71 -0
- kafka/protocol/schemas/resources/OffsetDeleteRequest.json +39 -0
- kafka/protocol/schemas/resources/OffsetDeleteResponse.json +42 -0
- kafka/protocol/schemas/resources/OffsetFetchRequest.json +76 -0
- kafka/protocol/schemas/resources/OffsetFetchResponse.json +107 -0
- kafka/protocol/schemas/resources/OffsetForLeaderEpochRequest.json +52 -0
- kafka/protocol/schemas/resources/OffsetForLeaderEpochResponse.json +51 -0
- kafka/protocol/schemas/resources/ProduceRequest.json +73 -0
- kafka/protocol/schemas/resources/ProduceResponse.json +96 -0
- kafka/protocol/schemas/resources/RequestHeader.json +44 -0
- kafka/protocol/schemas/resources/ResponseHeader.json +26 -0
- kafka/protocol/schemas/resources/SaslAuthenticateRequest.json +29 -0
- kafka/protocol/schemas/resources/SaslAuthenticateResponse.json +34 -0
- kafka/protocol/schemas/resources/SaslHandshakeRequest.json +31 -0
- kafka/protocol/schemas/resources/SaslHandshakeResponse.json +32 -0
- kafka/protocol/schemas/resources/SyncGroupRequest.json +56 -0
- kafka/protocol/schemas/resources/SyncGroupResponse.json +46 -0
- kafka/protocol/schemas/resources/TxnOffsetCommitRequest.json +68 -0
- kafka/protocol/schemas/resources/TxnOffsetCommitResponse.json +47 -0
- kafka/protocol/schemas/resources/UpdateFeaturesRequest.json +43 -0
- kafka/protocol/schemas/resources/UpdateFeaturesResponse.json +39 -0
- kafka/protocol/schemas/resources/WriteTxnMarkersRequest.json +49 -0
- kafka/protocol/schemas/resources/WriteTxnMarkersResponse.json +45 -0
- kafka/protocol/schemas/resources/__init__.py +0 -0
- kafka/record/__init__.py +3 -0
- kafka/record/_crc32c.py +161 -0
- kafka/record/abc.py +144 -0
- kafka/record/default_records.py +782 -0
- kafka/record/legacy_records.py +587 -0
- kafka/record/memory_records.py +255 -0
- kafka/record/util.py +135 -0
- kafka/serializer/__init__.py +4 -0
- kafka/serializer/abstract.py +20 -0
- kafka/serializer/default.py +16 -0
- kafka/serializer/json.py +17 -0
- kafka/serializer/wrapper.py +21 -0
- kafka/structs.py +69 -0
- kafka/util.py +159 -0
- kafka/vendor/__init__.py +0 -0
- kafka/version.py +1 -0
- kafka_python-3.0.0.dist-info/METADATA +319 -0
- kafka_python-3.0.0.dist-info/RECORD +373 -0
- kafka_python-3.0.0.dist-info/WHEEL +5 -0
- kafka_python-3.0.0.dist-info/entry_points.txt +2 -0
- kafka_python-3.0.0.dist-info/licenses/LICENSE +202 -0
- kafka_python-3.0.0.dist-info/top_level.txt +1 -0
kafka/util.py
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import binascii
|
|
2
|
+
import functools
|
|
3
|
+
import re
|
|
4
|
+
import time
|
|
5
|
+
import weakref
|
|
6
|
+
|
|
7
|
+
from kafka.errors import KafkaTimeoutError
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Timer:
|
|
11
|
+
__slots__ = ('_start_at', '_expire_at', '_timeout_ms', '_error_message')
|
|
12
|
+
|
|
13
|
+
def __init__(self, timeout_ms, error_message=None, start_at=None):
|
|
14
|
+
self._timeout_ms = timeout_ms
|
|
15
|
+
self._start_at = start_at or time.monotonic()
|
|
16
|
+
if timeout_ms is not None:
|
|
17
|
+
self._expire_at = self._start_at + timeout_ms / 1000
|
|
18
|
+
else:
|
|
19
|
+
self._expire_at = float('inf')
|
|
20
|
+
self._error_message = error_message
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def expired(self):
|
|
24
|
+
return time.monotonic() >= self._expire_at
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def timeout_ms(self):
|
|
28
|
+
if self._timeout_ms is None:
|
|
29
|
+
return None
|
|
30
|
+
elif self._expire_at == float('inf'):
|
|
31
|
+
return float('inf')
|
|
32
|
+
remaining = self._expire_at - time.monotonic()
|
|
33
|
+
if remaining < 0:
|
|
34
|
+
return 0
|
|
35
|
+
else:
|
|
36
|
+
return int(remaining * 1000)
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def timeout_secs(self):
|
|
40
|
+
timeout_ms = self.timeout_ms
|
|
41
|
+
return timeout_ms / 1000 if timeout_ms is not None else None
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def elapsed_ms(self):
|
|
45
|
+
return int(1000 * (time.monotonic() - self._start_at))
|
|
46
|
+
|
|
47
|
+
def maybe_raise(self):
|
|
48
|
+
if self.expired:
|
|
49
|
+
raise KafkaTimeoutError(self._error_message)
|
|
50
|
+
|
|
51
|
+
def __str__(self):
|
|
52
|
+
return "Timer(%s ms remaining)" % (self.timeout_ms)
|
|
53
|
+
|
|
54
|
+
# Taken from: https://github.com/apache/kafka/blob/39eb31feaeebfb184d98cc5d94da9148c2319d81/clients/src/main/java/org/apache/kafka/common/internals/Topic.java#L29
|
|
55
|
+
TOPIC_MAX_LENGTH = 249
|
|
56
|
+
TOPIC_LEGAL_CHARS = re.compile('^[a-zA-Z0-9._-]+$')
|
|
57
|
+
|
|
58
|
+
def ensure_valid_topic_name(topic):
|
|
59
|
+
""" Ensures that the topic name is valid according to the kafka source. """
|
|
60
|
+
|
|
61
|
+
# See Kafka Source:
|
|
62
|
+
# https://github.com/apache/kafka/blob/39eb31feaeebfb184d98cc5d94da9148c2319d81/clients/src/main/java/org/apache/kafka/common/internals/Topic.java
|
|
63
|
+
if topic is None:
|
|
64
|
+
raise TypeError('All topics must not be None')
|
|
65
|
+
if not isinstance(topic, str):
|
|
66
|
+
raise TypeError('All topics must be strings')
|
|
67
|
+
if len(topic) == 0:
|
|
68
|
+
raise ValueError('All topics must be non-empty strings')
|
|
69
|
+
if topic == '.' or topic == '..':
|
|
70
|
+
raise ValueError('Topic name cannot be "." or ".."')
|
|
71
|
+
if len(topic) > TOPIC_MAX_LENGTH:
|
|
72
|
+
raise ValueError('Topic name is illegal, it can\'t be longer than {0} characters, topic: "{1}"'.format(TOPIC_MAX_LENGTH, topic))
|
|
73
|
+
if not TOPIC_LEGAL_CHARS.match(topic):
|
|
74
|
+
raise ValueError('Topic name "{0}" is illegal, it contains a character other than ASCII alphanumerics, ".", "_" and "-"'.format(topic))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class WeakMethod:
|
|
78
|
+
"""
|
|
79
|
+
Callable that weakly references a method and the object it is bound to. It
|
|
80
|
+
is based on https://stackoverflow.com/a/24287465.
|
|
81
|
+
|
|
82
|
+
Arguments:
|
|
83
|
+
|
|
84
|
+
object_dot_method: A bound instance method (i.e. 'object.method').
|
|
85
|
+
"""
|
|
86
|
+
def __init__(self, object_dot_method):
|
|
87
|
+
try:
|
|
88
|
+
self.target = weakref.ref(object_dot_method.__self__)
|
|
89
|
+
except AttributeError:
|
|
90
|
+
self.target = weakref.ref(object_dot_method.im_self)
|
|
91
|
+
self._target_id = id(self.target())
|
|
92
|
+
try:
|
|
93
|
+
self.method = weakref.ref(object_dot_method.__func__)
|
|
94
|
+
except AttributeError:
|
|
95
|
+
self.method = weakref.ref(object_dot_method.im_func)
|
|
96
|
+
self._method_id = id(self.method())
|
|
97
|
+
|
|
98
|
+
def __call__(self, *args, **kwargs):
|
|
99
|
+
"""
|
|
100
|
+
Calls the method on target with args and kwargs.
|
|
101
|
+
"""
|
|
102
|
+
return self.method()(self.target(), *args, **kwargs)
|
|
103
|
+
|
|
104
|
+
def __hash__(self):
|
|
105
|
+
return hash(self.target) ^ hash(self.method)
|
|
106
|
+
|
|
107
|
+
def __eq__(self, other):
|
|
108
|
+
if not isinstance(other, WeakMethod):
|
|
109
|
+
return False
|
|
110
|
+
return self._target_id == other._target_id and self._method_id == other._method_id
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class Dict(dict):
|
|
114
|
+
"""Utility class to support passing weakrefs to dicts
|
|
115
|
+
|
|
116
|
+
See: https://docs.python.org/2/library/weakref.html
|
|
117
|
+
"""
|
|
118
|
+
pass
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def synchronized(func):
|
|
122
|
+
def wrapper(self, *args, **kwargs):
|
|
123
|
+
with self._lock:
|
|
124
|
+
return func(self, *args, **kwargs)
|
|
125
|
+
functools.update_wrapper(wrapper, func)
|
|
126
|
+
return wrapper
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class classproperty:
|
|
130
|
+
def __init__(self, f):
|
|
131
|
+
self.f = f
|
|
132
|
+
def __get__(self, obj, owner):
|
|
133
|
+
return self.f(owner)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class EnumHelper:
|
|
137
|
+
@classmethod
|
|
138
|
+
def build_from(cls, val):
|
|
139
|
+
if isinstance(val, cls):
|
|
140
|
+
return val
|
|
141
|
+
try:
|
|
142
|
+
return cls(val)
|
|
143
|
+
except ValueError:
|
|
144
|
+
pass
|
|
145
|
+
try:
|
|
146
|
+
return cls[str(val).strip().upper().replace('-', '_')] # pylint: disable=E1136
|
|
147
|
+
except KeyError:
|
|
148
|
+
raise ValueError(f'Unrecognized {cls.__name__}: {val}') from None
|
|
149
|
+
|
|
150
|
+
@classmethod
|
|
151
|
+
def value_for(cls, val):
|
|
152
|
+
if isinstance(val, cls):
|
|
153
|
+
return val.value
|
|
154
|
+
if isinstance(val, int):
|
|
155
|
+
return cls(val).value # pylint: disable=E1101
|
|
156
|
+
try:
|
|
157
|
+
return cls[str(val).upper().replace('-', '_')].value # pylint: disable=E1136
|
|
158
|
+
except KeyError:
|
|
159
|
+
raise ValueError(f'Unrecognized {cls.__name__}: {val}') from None
|
kafka/vendor/__init__.py
ADDED
|
File without changes
|
kafka/version.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '3.0.0'
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kafka-python
|
|
3
|
+
Version: 3.0.0
|
|
4
|
+
Summary: Pure Python client for Apache Kafka
|
|
5
|
+
Author-email: Dana Powers <dana.powers@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/dpkp/kafka-python
|
|
8
|
+
Project-URL: Documentation, https://kafka-python.readthedocs.io
|
|
9
|
+
Project-URL: Repository, https://github.com/dpkp/kafka-python
|
|
10
|
+
Project-URL: Issues, https://github.com/dpkp/kafka-python/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/dpkp/kafka-python/blob/master/CHANGES.md
|
|
12
|
+
Keywords: apache kafka,kafka
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
25
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
+
Requires-Python: >=3.8
|
|
28
|
+
Description-Content-Type: text/x-rst
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Provides-Extra: crc32c
|
|
31
|
+
Requires-Dist: crc32c; extra == "crc32c"
|
|
32
|
+
Provides-Extra: lz4
|
|
33
|
+
Requires-Dist: lz4; extra == "lz4"
|
|
34
|
+
Provides-Extra: snappy
|
|
35
|
+
Requires-Dist: python-snappy; extra == "snappy"
|
|
36
|
+
Provides-Extra: zstd
|
|
37
|
+
Requires-Dist: zstandard; extra == "zstd"
|
|
38
|
+
Provides-Extra: testing
|
|
39
|
+
Requires-Dist: pytest; extra == "testing"
|
|
40
|
+
Requires-Dist: pytest-mock; extra == "testing"
|
|
41
|
+
Requires-Dist: pytest-timeout; extra == "testing"
|
|
42
|
+
Provides-Extra: benchmarks
|
|
43
|
+
Requires-Dist: pyperf; extra == "benchmarks"
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
|
|
46
|
+
kafka-python
|
|
47
|
+
############
|
|
48
|
+
|
|
49
|
+
.. image:: https://img.shields.io/pypi/v/kafka-python.svg
|
|
50
|
+
:target: https://pypi.org/project/kafka-python
|
|
51
|
+
.. image:: https://img.shields.io/badge/kafka-4.3--0.8-brightgreen.svg
|
|
52
|
+
:target: https://kafka-python.readthedocs.io/en/master/compatibility.html
|
|
53
|
+
|
|
54
|
+
.. image:: https://img.shields.io/badge/license-Apache%202-blue.svg
|
|
55
|
+
:target: https://github.com/dpkp/kafka-python/blob/master/LICENSE
|
|
56
|
+
.. image:: https://img.shields.io/pypi/pyversions/kafka-python.svg
|
|
57
|
+
:target: https://pypi.python.org/pypi/kafka-python
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
kafka-python is a pure-python client library for Apache Kafka, the distributed
|
|
61
|
+
stream processing engine. It has no external dependencies and no Cython/C/rust
|
|
62
|
+
core, making installation across a wide variety of environments simple and easy
|
|
63
|
+
to manage. It provides high-level class components for consumer, producer, and
|
|
64
|
+
admin clients, as well as CLI scripts for quick interactive tasks.
|
|
65
|
+
|
|
66
|
+
``kafka-python admin`` serves as a simple alternative to the apache kafka bin/
|
|
67
|
+
scripts, particularly if/when you do not have easy access to an
|
|
68
|
+
installed/compatible jvm. The CLI interface for admin commands is provided as
|
|
69
|
+
``kafka-python admin`` and ``python -m kafka.admin``.
|
|
70
|
+
|
|
71
|
+
Users looking to add more raw throughput can ``pip install crc32c`` as
|
|
72
|
+
an optional dependency, offloading one of the most CPU intensive subsystems
|
|
73
|
+
to an optimized C library.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
.. code-block:: bash
|
|
77
|
+
|
|
78
|
+
pip install kafka-python
|
|
79
|
+
|
|
80
|
+
# callable as module or as cli-script
|
|
81
|
+
kafka-python admin -b localhost:9092 cluster describe
|
|
82
|
+
|
|
83
|
+
# Create a topic with the admin cli
|
|
84
|
+
python -m kafka.admin -b localhost:9092 topics create -t foo-topic
|
|
85
|
+
|
|
86
|
+
# Produce messages
|
|
87
|
+
echo "foo message" | python -m kafka.producer -b localhost:9092 -t foo-topic
|
|
88
|
+
|
|
89
|
+
# Consume messages
|
|
90
|
+
python -m kafka.consumer -b localhost:9092 -C auto_offset_reset=earliest -C consumer_timeout_ms=1000 -g foo-group -t foo-topic
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
What's New in 3.0
|
|
94
|
+
*****************
|
|
95
|
+
|
|
96
|
+
- Protocol Stack dynamically generated from Apache Kafka json message schemas.
|
|
97
|
+
- Encode/decode performance optimizations with compiled/cached python bytecode.
|
|
98
|
+
- Expanded KIP feature support, including Cooperative Rebalance (KIP-429),
|
|
99
|
+
Rack-aware Fetch (KIP-392), Log-Truncation detection (KIP-320), Transactional
|
|
100
|
+
Producer improvements (KIP-360, KIP-447, KIP-654), Sticky Partitioner (KIP-480),
|
|
101
|
+
and splittting oversized producer batches (KIP-126).
|
|
102
|
+
- Full refactor and expansion of KafkaAdminClient.
|
|
103
|
+
- Networking changes to leverage kafka.net event-loop and async/await syntax.
|
|
104
|
+
- Python 3.8+ required
|
|
105
|
+
|
|
106
|
+
KafkaConsumer
|
|
107
|
+
*************
|
|
108
|
+
|
|
109
|
+
KafkaConsumer is a high-level message consumer, intended to operate as similarly
|
|
110
|
+
as possible to the official java client.
|
|
111
|
+
See https://kafka-python.readthedocs.io/en/master/apidoc/KafkaConsumer.html
|
|
112
|
+
for API and configuration details.
|
|
113
|
+
|
|
114
|
+
The consumer iterator returns ConsumerRecords, which are simple namedtuples
|
|
115
|
+
that expose basic message attributes: topic, partition, offset, key, and value:
|
|
116
|
+
|
|
117
|
+
.. code-block:: python
|
|
118
|
+
|
|
119
|
+
from kafka import KafkaConsumer
|
|
120
|
+
consumer = KafkaConsumer('my_favorite_topic')
|
|
121
|
+
for msg in consumer:
|
|
122
|
+
print (msg)
|
|
123
|
+
|
|
124
|
+
.. code-block:: python
|
|
125
|
+
|
|
126
|
+
# join a consumer group for dynamic partition assignment and offset commits
|
|
127
|
+
from kafka import KafkaConsumer
|
|
128
|
+
consumer = KafkaConsumer('my_favorite_topic', group_id='my_favorite_group')
|
|
129
|
+
for msg in consumer:
|
|
130
|
+
print (msg)
|
|
131
|
+
|
|
132
|
+
.. code-block:: python
|
|
133
|
+
|
|
134
|
+
# manually assign the partition list for the consumer
|
|
135
|
+
from kafka import KafkaConsumer, TopicPartition
|
|
136
|
+
consumer = KafkaConsumer(bootstrap_servers='localhost:1234')
|
|
137
|
+
consumer.assign([TopicPartition('foobar', 2)])
|
|
138
|
+
msg = next(consumer)
|
|
139
|
+
|
|
140
|
+
Keys and Values returned by KafkaConsumer will be raw bytes by default. Use a
|
|
141
|
+
``value_deserializer`` to automatically decode into something else. Helpers
|
|
142
|
+
are available for simple utf-8 string decoding (``DefaultSerializer``) and
|
|
143
|
+
json (``JsonSerializer``).
|
|
144
|
+
|
|
145
|
+
.. code-block:: python
|
|
146
|
+
|
|
147
|
+
# Deserialize json-encoded values
|
|
148
|
+
from kafka import KafkaConsumer, JsonSerializer
|
|
149
|
+
consumer = KafkaConsumer(value_deserializer=JsonSerializer())
|
|
150
|
+
consumer.subscribe(['json-foo'])
|
|
151
|
+
for msg in consumer:
|
|
152
|
+
assert isinstance(msg.value, dict)
|
|
153
|
+
|
|
154
|
+
.. code-block:: python
|
|
155
|
+
|
|
156
|
+
# Access record headers. The returned value is a list of
|
|
157
|
+
# (str, bytes) tuples, representing the header key and value.
|
|
158
|
+
for msg in consumer:
|
|
159
|
+
print (msg.headers)
|
|
160
|
+
|
|
161
|
+
.. code-block:: python
|
|
162
|
+
|
|
163
|
+
# Read only committed messages from transactional topic
|
|
164
|
+
from kafka import KafkaConsumer, IsolationLevel
|
|
165
|
+
consumer = KafkaConsumer(isolation_level=IsolationLevel.READ_COMMITTED)
|
|
166
|
+
consumer.subscribe(['txn_topic'])
|
|
167
|
+
for msg in consumer:
|
|
168
|
+
print(msg)
|
|
169
|
+
|
|
170
|
+
.. code-block:: python
|
|
171
|
+
|
|
172
|
+
# Get consumer metrics
|
|
173
|
+
metrics = consumer.metrics()
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
KafkaProducer
|
|
177
|
+
*************
|
|
178
|
+
|
|
179
|
+
KafkaProducer is a high-level, asynchronous message producer. The class is
|
|
180
|
+
intended to operate as similarly as possible to the official java client.
|
|
181
|
+
See https://kafka-python.readthedocs.io/en/master/apidoc/KafkaProducer.html
|
|
182
|
+
for more details.
|
|
183
|
+
|
|
184
|
+
.. code-block:: python
|
|
185
|
+
|
|
186
|
+
from kafka import KafkaProducer
|
|
187
|
+
producer = KafkaProducer(bootstrap_servers='localhost:1234')
|
|
188
|
+
for _ in range(100):
|
|
189
|
+
# Fire-and-forget: send() is async and returns before delivery
|
|
190
|
+
producer.send('foobar', b'some_message_bytes')
|
|
191
|
+
|
|
192
|
+
.. code-block:: python
|
|
193
|
+
|
|
194
|
+
# To check the status of an async message delivery, use .get()
|
|
195
|
+
future = producer.send('foobar', b'another_message')
|
|
196
|
+
# future.get() will block until it can return the result or raise on error
|
|
197
|
+
result = future.get(timeout=60)
|
|
198
|
+
|
|
199
|
+
.. code-block:: python
|
|
200
|
+
|
|
201
|
+
# Block until all pending messages are at least put on the network
|
|
202
|
+
# NOTE: This does not guarantee delivery or success! It is really
|
|
203
|
+
# only useful if you configure internal batching using linger_ms
|
|
204
|
+
producer.flush()
|
|
205
|
+
|
|
206
|
+
Message keys are used to hash messages with the same key to the same
|
|
207
|
+
partition. Both keys and values should be raw bytes unless a serializer is configured.
|
|
208
|
+
|
|
209
|
+
.. code-block:: python
|
|
210
|
+
|
|
211
|
+
# Use a key for hashed-partitioning
|
|
212
|
+
producer.send('foobar', key=b'foo', value=b'bar')
|
|
213
|
+
|
|
214
|
+
.. code-block:: python
|
|
215
|
+
|
|
216
|
+
# Serialize json messages
|
|
217
|
+
from kafka import KafkaProducer, JsonSerializer
|
|
218
|
+
producer = KafkaProducer(value_serializer=JsonSerializer())
|
|
219
|
+
producer.send('fizzbuzz', {'foo': 'bar'})
|
|
220
|
+
|
|
221
|
+
.. code-block:: python
|
|
222
|
+
|
|
223
|
+
# Serialize string keys
|
|
224
|
+
from kafka import KafkaProducer, DefaultSerializer
|
|
225
|
+
producer = KafkaProducer(key_serializer=DefaultSerializer())
|
|
226
|
+
producer.send('flipflap', key='ping', value=b'1234')
|
|
227
|
+
|
|
228
|
+
Compression can be used to reduce message size on the wire. Gzip is supported
|
|
229
|
+
via python stdlib. For other compression types you must install optional
|
|
230
|
+
dependencies.
|
|
231
|
+
|
|
232
|
+
.. code-block:: python
|
|
233
|
+
|
|
234
|
+
# Compress messages
|
|
235
|
+
producer = KafkaProducer(compression_type='gzip')
|
|
236
|
+
for i in range(1000):
|
|
237
|
+
producer.send('foobar', b'msg %d' % i)
|
|
238
|
+
|
|
239
|
+
KafkaProducer also supports transactions and message headers when needed.
|
|
240
|
+
|
|
241
|
+
.. code-block:: python
|
|
242
|
+
|
|
243
|
+
# Use transactions
|
|
244
|
+
producer = KafkaProducer(transactional_id='fizzbuzz')
|
|
245
|
+
producer.init_transactions()
|
|
246
|
+
producer.begin_transaction()
|
|
247
|
+
future = producer.send('txn_topic', value=b'yes')
|
|
248
|
+
future.get() # wait for successful produce
|
|
249
|
+
producer.commit_transaction() # commit the transaction
|
|
250
|
+
|
|
251
|
+
producer.begin_transaction()
|
|
252
|
+
future = producer.send('txn_topic', value=b'no')
|
|
253
|
+
future.get() # wait for successful produce
|
|
254
|
+
producer.abort_transaction() # abort the transaction
|
|
255
|
+
|
|
256
|
+
.. code-block:: python
|
|
257
|
+
|
|
258
|
+
# Include record headers. The format is list of tuples with string key
|
|
259
|
+
# and bytes value.
|
|
260
|
+
producer.send('foobar', value=b'c29tZSB2YWx1ZQ==', headers=[('content-encoding', b'base64')])
|
|
261
|
+
|
|
262
|
+
.. code-block:: python
|
|
263
|
+
|
|
264
|
+
# Get producer performance metrics
|
|
265
|
+
metrics = producer.metrics()
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
Module CLI Interface
|
|
269
|
+
********************
|
|
270
|
+
|
|
271
|
+
kafka-python also provides simple command-line interfaces for consumer, producer, and admin clients.
|
|
272
|
+
Access via ``python -m kafka.consumer``, ``python -m kafka.producer``, and ``python -m kafka.admin``.
|
|
273
|
+
See https://kafka-python.readthedocs.io/en/master/usage.html for more details.
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
Compression
|
|
277
|
+
***********
|
|
278
|
+
|
|
279
|
+
kafka-python supports the following compression formats:
|
|
280
|
+
|
|
281
|
+
- gzip (via stdlib)
|
|
282
|
+
- LZ4 (via `python-lz4`, `lz4tools`, or `py-lz4framed`)
|
|
283
|
+
- Snappy (via `python-snappy`)
|
|
284
|
+
- Zstandard (via `python-zstandard`)
|
|
285
|
+
|
|
286
|
+
gzip is supported natively, the others require installing additional libraries.
|
|
287
|
+
See https://kafka-python.readthedocs.io/en/master/install.html for more information.
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
Optimized CRC32 Validation
|
|
291
|
+
**************************
|
|
292
|
+
|
|
293
|
+
Kafka uses CRC32 checksums to validate messages. kafka-python includes a pure
|
|
294
|
+
python implementation for compatibility. To improve performance for high-throughput
|
|
295
|
+
applications, kafka-python will use `crc32c` for optimized native code if installed.
|
|
296
|
+
See https://kafka-python.readthedocs.io/en/master/install.html for installation instructions.
|
|
297
|
+
See https://pypi.org/project/crc32c/ for details on the underlying crc32c lib.
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
Protocol
|
|
301
|
+
********
|
|
302
|
+
|
|
303
|
+
A secondary goal of kafka-python is to provide an easy-to-use protocol layer
|
|
304
|
+
for interacting with kafka brokers via the python repl. This is useful for
|
|
305
|
+
testing, probing, and general experimentation. In version 3.0 the protocol
|
|
306
|
+
layer was re-written to generate encoder/decoder classes using json message
|
|
307
|
+
definitions imported directly from the Apache Kafka project source.
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
Debugging
|
|
311
|
+
*********
|
|
312
|
+
|
|
313
|
+
Use python's `logging` module to view internal operational events.
|
|
314
|
+
See https://docs.python.org/3/howto/logging.html for overview / howto.
|
|
315
|
+
|
|
316
|
+
.. code-block:: python
|
|
317
|
+
|
|
318
|
+
import logging
|
|
319
|
+
logging.basicConfig(level=logging.DEBUG)
|