Skip to content

Commit ca756d3

Browse files
author
Gabriel Tincu
committed
Update docstring, always force api version to be in sync with actual broker running when building producer
1 parent 519610e commit ca756d3

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

docs/index.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ multiprocessing is recommended.
122122
Compression
123123
***********
124124

125-
kafka-python supports gzip compression/decompression natively. To produce or
126-
consume lz4 compressed messages, you should install python-lz4 (pip install lz4).
127-
To enable snappy, install python-snappy (also requires snappy library).
128-
See `Installation <install.html#optional-snappy-install>`_ for more information.
129-
125+
kafka-python supports multiple compression types. To produce or
126+
- gzip : supported natively
127+
- lz4 : requires `python-lz4 <https://pypi.org/project/lz4/>`_ installed
128+
- snappy : requires the `python-snappy <https://pypi.org/project/python-snappy/>`_ package (which requires the snappy C library)
129+
- zstd : requires the `python-zstandard <https://github.com/indygreg/python-zstandard>`_ package installed
130130

131131
Protocol
132132
********

test/test_producer.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def test_buffer_pool():
2525
@pytest.mark.skipif(not env_kafka_version(), reason="No KAFKA_VERSION set")
2626
@pytest.mark.parametrize("compression", [None, 'gzip', 'snappy', 'lz4', 'zstd'])
2727
def test_end_to_end(kafka_broker, compression):
28-
2928
if compression == 'lz4':
3029
# LZ4 requires 0.8.2
3130
if env_kafka_version() < (0, 8, 2):
@@ -36,13 +35,12 @@ def test_end_to_end(kafka_broker, compression):
3635

3736
if compression == 'zstd' and env_kafka_version() < (2, 1, 0):
3837
return
39-
env_version = env_kafka_version()
40-
api_version = env_version if env_version >= (2, 1, 0) else None
38+
4139
connect_str = ':'.join([kafka_broker.host, str(kafka_broker.port)])
4240
producer = KafkaProducer(bootstrap_servers=connect_str,
4341
retries=5,
4442
max_block_ms=30000,
45-
api_version=api_version,
43+
api_version=env_kafka_version(),
4644
compression_type=compression,
4745
value_serializer=str.encode)
4846
consumer = KafkaConsumer(bootstrap_servers=connect_str,
@@ -91,11 +89,9 @@ def test_kafka_producer_proper_record_metadata(kafka_broker, compression):
9189
if compression == 'zstd' and env_kafka_version() < (2, 1, 0):
9290
return
9391
connect_str = ':'.join([kafka_broker.host, str(kafka_broker.port)])
94-
env_version = env_kafka_version()
95-
api_version = env_version if env_version >= (2, 1, 0) else None
9692
producer = KafkaProducer(bootstrap_servers=connect_str,
9793
retries=5,
98-
api_version=api_version,
94+
api_version=env_kafka_version(),
9995
max_block_ms=30000,
10096
compression_type=compression)
10197
magic = producer._max_usable_produce_magic()

0 commit comments

Comments
 (0)