Skip to content

Commit 1652550

Browse files
committed
Improved README
1 parent a2fbbf6 commit 1652550

File tree

1 file changed

+66
-16
lines changed

1 file changed

+66
-16
lines changed

README.md

Lines changed: 66 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,94 @@
11
Confluent's Apache Kafka client for Python
22
==========================================
33

4+
Confluent's Kafka client for Python wraps the librdkafka C library, providing
5+
full Kafka protocol support at great performance and reliability.
46

5-
Prerequisites
6-
===============
7+
The Python bindings provides a high-level Producer and Consumer with support
8+
for the balanced consumer groups of Apache Kafka 0.9.
79

8-
librdkafka >=0.9.1 (or master>=2016-04-13)
9-
py.test (pip install pytest)
10+
See the [API documentation](http://docs.confluent.io/3.0.0/clients/confluent-kafka-python/index.html) for more info.
1011

1112

12-
Build
13+
Usage
1314
=====
1415

15-
python setup.by build
16+
**Producer:**
17+
18+
from confluent_kafka import Producer
19+
20+
p = Producer({'bootstrap.servers': 'mybroker,mybroker2'})
21+
for data in some_data_source:
22+
p.produce('mytopic', data.encode('utf-8'))
23+
p.flush()
24+
25+
26+
**High-level Consumer:**
27+
28+
from confluent_kafka import Consumer
29+
30+
c = Consumer({'bootstrap.servers': 'mybroker', 'group.id': 'mygroup',
31+
'default.topic.config': {'auto.offset.reset': 'smallest'}})
32+
c.subscribe(['mytopic'])
33+
while running:
34+
msg = c.poll()
35+
if not msg.error():
36+
print('Received message: %s' % msg.value().decode('utf-8'))
37+
c.close()
38+
39+
40+
41+
See [examples](examples) for more examples.
42+
43+
44+
45+
Prerequisites
46+
=============
47+
48+
* Python >= 2.7 or Python 3.x
49+
* [librdkafka](https://github.com/edenhill/librdkafka) >= 0.9.1
1650

1751

1852

1953
Install
2054
=======
21-
Preferably in a virtualenv:
55+
56+
**Install from PyPi:**
57+
58+
pip install confluent-kafka
59+
60+
61+
**Install from source / tarball:**
2262

2363
pip install .
2464

2565

26-
Run unit-tests
27-
==============
66+
Build
67+
=====
68+
69+
python setup.by build
70+
71+
72+
73+
74+
Tests
75+
=====
76+
77+
78+
**Run unit-tests:**
2879

2980
py.test
3081

82+
**NOTE**: Requires py.test, install by `pip install pytest`
3183

32-
Run integration tests
33-
=====================
34-
**WARNING**: These tests require an active Kafka cluster and will make use of a topic named 'test'.
84+
85+
**Run integration tests:**
3586

3687
examples/integration_test.py <kafka-broker>
3788

89+
**WARNING**: These tests require an active Kafka cluster and will make use of a topic named 'test'.
90+
91+
3892

3993

4094
Generate documentation
@@ -51,7 +105,3 @@ or:
51105
Documentation will be generated in `docs/_build/`
52106

53107

54-
Examples
55-
========
56-
57-
See [examples](examples)

0 commit comments

Comments
 (0)