Skip to content

Commit 2805c3f

Browse files
authored
Merge pull request confluentinc#695 from confluentinc/docs1
Iterating on the docs
2 parents c20c535 + 5c34474 commit 2805c3f

File tree

2 files changed

+87
-69
lines changed

2 files changed

+87
-69
lines changed

DEVELOPER.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Developer Notes
2+
3+
This document provides information useful to developers working on confluent-kafka-python.
4+
5+
6+
## Build
7+
8+
$ python setup.py build
9+
10+
If librdkafka is installed in a non-standard location provide the include and library directories with:
11+
12+
$ C_INCLUDE_PATH=/path/to/include LIBRARY_PATH=/path/to/lib python setup.py ...
13+
14+
15+
## Generate Documentation
16+
17+
Install sphinx and sphinx_rtd_theme packages:
18+
19+
$ pip install sphinx sphinx_rtd_theme
20+
21+
Build HTML docs:
22+
23+
$ make docs
24+
25+
or:
26+
27+
$ python setup.py build_sphinx
28+
29+
Documentation will be generated in `docs/_build/`.
30+
31+
32+
## Tests
33+
34+
35+
See [tests/README.md](tests/README.md) for instructions on how to run tests.
36+

README.md

Lines changed: 51 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,19 @@
11
Confluent's Python Client for Apache Kafka<sup>TM</sup>
22
=======================================================
33

4-
**confluent-kafka-python** is Confluent's Python client for [Apache Kafka](http://kafka.apache.org/) and the
5-
[Confluent Platform](https://www.confluent.io/product/compare/).
4+
**confluent-kafka-python** provides a high-level Producer, Consumer and AdminClient compatible with all
5+
[Apache Kafka<sup>TM<sup>](http://kafka.apache.org/) brokers >= v0.8, [Confluent Cloud](https://www.confluent.io/confluent-cloud/)
6+
and the [Confluent Platform](https://www.confluent.io/product/compare/). The client is:
67

7-
Features:
8+
- **Reliable** - It's a wrapper around [librdkafka](https://github.com/edenhill/librdkafka) (provided automatically via binary wheels) which is widely deployed in a diverse set of production scenarios. It's tested using [the same set of system tests](https://github.com/confluentinc/confluent-kafka-python/tree/master/confluent_kafka/kafkatest) as the Java client [and more](https://github.com/confluentinc/confluent-kafka-python/tree/master/tests). It's supported by [Confluent](https://confluent.io).
89

9-
- **High performance** - confluent-kafka-python is a lightweight wrapper around
10-
[librdkafka](https://github.com/edenhill/librdkafka), a finely tuned C
11-
client.
12-
13-
- **Reliability** - There are a lot of details to get right when writing an Apache Kafka
14-
client. We get them right in one place (librdkafka) and leverage this work
15-
across all of our clients (also [confluent-kafka-go](https://github.com/confluentinc/confluent-kafka-go)
16-
and [confluent-kafka-dotnet](https://github.com/confluentinc/confluent-kafka-dotnet)).
17-
18-
- **Supported** - Commercial support is offered by
19-
[Confluent](https://confluent.io/).
10+
- **Performant** - Performance is a key design consideration. Maximum throughput is on par with the Java client for larger message sizes (where the overhead of the Python interpreter has less impact). Latency is on par with the Java client.
2011

2112
- **Future proof** - Confluent, founded by the
2213
creators of Kafka, is building a [streaming platform](https://www.confluent.io/product/compare/)
2314
with Apache Kafka at its core. It's high priority for us that client features keep
2415
pace with core Apache Kafka and components of the [Confluent Platform](https://www.confluent.io/product/compare/).
2516

26-
The Python bindings provides a high-level Producer and Consumer with support
27-
for the balanced consumer groups of Apache Kafka &gt;= 0.9.
2817

2918
See the [API documentation](http://docs.confluent.io/current/clients/confluent-kafka-python/index.html) for more info.
3019

@@ -34,7 +23,10 @@ See the [API documentation](http://docs.confluent.io/current/clients/confluent-k
3423
Usage
3524
=====
3625

37-
**Producer:**
26+
Below are some examples of typical usage. For more examples, see the [examples](examples) directory or the [confluentinc/examples](https://github.com/confluentinc/examples/tree/master/clients/cloud/python) github repo for a [Confluent Cloud](https://www.confluent.io/confluent-cloud/) example.
27+
28+
29+
**Producer**
3830

3931
```python
4032
from confluent_kafka import Producer
@@ -65,7 +57,7 @@ p.flush()
6557
```
6658

6759

68-
**High-level Consumer:**
60+
**High-level Consumer**
6961

7062
```python
7163
from confluent_kafka import Consumer, KafkaError
@@ -177,28 +169,58 @@ while True:
177169
c.close()
178170
```
179171

180-
See the [examples](examples) directory for more examples, including [how to configure](examples/confluent_cloud.py) the python client for use with
181-
[Confluent Cloud](https://www.confluent.io/confluent-cloud/).
172+
**AdminClient**
173+
174+
Create topics:
175+
176+
```python
177+
from confluent_kafka.admin import AdminClient, NewTopic
178+
179+
a = AdminClient({'bootstrap.servers': 'mybroker'})
180+
181+
new_topics = [NewTopic(topic, num_partitions=3, replication_factor=1) for topic in ["topic1", "topic2"]]
182+
# Note: In a multi-cluster production scenario, it is more typical to use a replication_factor of 3 for durability.
183+
184+
# Call create_topics to asynchronously create topics. A dict
185+
# of <topic,future> is returned.
186+
fs = a.create_topics(new_topics)
187+
188+
# Wait for each operation to finish.
189+
for topic, f in fs.items():
190+
try:
191+
f.result() # The result itself is None
192+
print("Topic {} created".format(topic))
193+
except Exception as e:
194+
print("Failed to create topic {}: {}".format(topic, e))
195+
```
196+
197+
198+
199+
Thread Safety
200+
-------------
201+
202+
The `Producer`, `Consumer` and `AdminClient` are all thread safe.
182203

183204

184205
Install
185206
=======
186207

208+
**Install self-contained binary wheels**
209+
210+
$ pip install confluent-kafka
211+
187212
**NOTE:** The pre-built Linux wheels do NOT contain SASL Kerberos/GSSAPI support.
188213
If you need SASL Kerberos/GSSAPI support you must install librdkafka and
189214
its dependencies using the repositories below and then build
190215
confluent-kafka using the command in the "Install from
191216
source from PyPi" section below.
192217

193-
**Install self-contained binary wheels for OSX and Linux from PyPi:**
194-
195-
$ pip install confluent-kafka
196-
197-
**Install AvroProducer and AvroConsumer:**
218+
**Install AvroProducer and AvroConsumer**
198219

199220
$ pip install "confluent-kafka[avro]"
200221

201-
**Install from source from PyPi** *(requires librdkafka + dependencies to be installed separately)*:
222+
**Install from source from PyPi**
223+
*(requires librdkafka + dependencies to be installed separately)*:
202224

203225
$ pip install --no-binary :all: confluent-kafka
204226

@@ -267,47 +289,7 @@ http://docs.confluent.io/current/installation.html#rpm-packages-via-yum
267289
* On **OSX**, use **homebrew** and do `brew install librdkafka`
268290

269291

270-
Build
271-
=====
272-
273-
$ python setup.py build
274-
275-
If librdkafka is installed in a non-standard location provide the include and library directories with:
276-
277-
$ C_INCLUDE_PATH=/path/to/include LIBRARY_PATH=/path/to/lib python setup.py ...
278-
279-
280-
Tests
281-
=====
282-
283-
284-
**Run unit-tests:**
285-
286-
In order to run full test suite, simply execute:
287-
288-
$ tox -r
289-
290-
**NOTE**: Requires `tox` (please install with `pip install tox`), several supported versions of Python on your path, and `librdkafka` [installed](tools/bootstrap-librdkafka.sh) into `tmp-build`.
291-
292-
293-
**Integration tests:**
294-
295-
See [tests/README.md](tests/README.md) for instructions on how to run integration tests.
296-
297-
298-
299-
Generate Documentation
300-
======================
301-
Install sphinx and sphinx_rtd_theme packages:
302-
303-
$ pip install sphinx sphinx_rtd_theme
304-
305-
Build HTML docs:
306-
307-
$ make docs
308-
309-
or:
310-
311-
$ python setup.py build_sphinx
292+
Developer Notes
293+
===============
312294

313-
Documentation will be generated in `docs/_build/`.
295+
Instructions on building and testing confluent-kafka-python can be found [here](DEVELOPER.md).

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy