@@ -17,62 +17,62 @@ Usage
17
17
18
18
** Producer:**
19
19
20
- from confluent_kafka import Producer
20
+ ``` python
21
+ from confluent_kafka import Producer
21
22
22
- p = Producer({'bootstrap.servers': 'mybroker,mybroker2'})
23
- for data in some_data_source:
24
- p.produce('mytopic', data.encode('utf-8'))
25
- p.flush()
23
+ p = Producer({' bootstrap.servers' : ' mybroker,mybroker2' })
24
+ for data in some_data_source:
25
+ p.produce(' mytopic' , data.encode(' utf-8' ))
26
+ p.flush()
27
+ ```
26
28
27
29
28
30
** High-level Consumer:**
29
31
30
- from confluent_kafka import Consumer
31
-
32
- c = Consumer({'bootstrap.servers': 'mybroker', 'group.id': 'mygroup',
33
- 'default.topic.config': {'auto.offset.reset': 'smallest'}})
34
- c.subscribe(['mytopic'])
35
- while running:
36
- msg = c.poll()
37
- if not msg.error():
38
- print('Received message: %s' % msg.value().decode('utf-8'))
39
- c.close()
40
-
32
+ ``` python
33
+ from confluent_kafka import Consumer
41
34
35
+ c = Consumer({' bootstrap.servers' : ' mybroker' , ' group.id' : ' mygroup' ,
36
+ ' default.topic.config' : {' auto.offset.reset' : ' smallest' }})
37
+ c.subscribe([' mytopic' ])
38
+ while running:
39
+ msg = c.poll()
40
+ if not msg.error():
41
+ print (' Received message: %s ' % msg.value().decode(' utf-8' ))
42
+ c.close()
43
+ ```
42
44
43
45
See [ examples] ( examples ) for more examples.
44
46
45
47
46
-
47
48
Prerequisites
48
49
=============
49
50
50
51
* Python >= 2.7 or Python 3.x
51
52
* [ librdkafka] ( https://github.com/edenhill/librdkafka ) >= 0.9.1
52
53
53
54
54
-
55
55
Install
56
56
=======
57
57
58
58
** Install from PyPi:**
59
59
60
- pip install confluent-kafka
60
+ $ pip install confluent-kafka
61
61
62
62
63
63
** Install from source / tarball:**
64
64
65
- pip install .
65
+ $ pip install .
66
66
67
67
68
68
Build
69
69
=====
70
70
71
- python setup.by build
71
+ $ python setup.by build
72
72
73
73
If librdkafka is installed in a non-standard location provide the include and library directories with:
74
74
75
- CPLUS_INCLUDE_PATH=/path/to/include LIBRARY_PATH=/path/to/lib python setup.py ...
75
+ $ CPLUS_INCLUDE_PATH=/path/to/include LIBRARY_PATH=/path/to/lib python setup.py ...
76
76
77
77
78
78
Tests
@@ -81,14 +81,14 @@ Tests
81
81
82
82
** Run unit-tests:**
83
83
84
- py.test
84
+ $ py.test
85
85
86
- ** NOTE** : Requires py.test, install by ` pip install pytest `
86
+ ** NOTE** : Requires ` py.test ` , install by ` pip install pytest `
87
87
88
88
89
89
** Run integration tests:**
90
90
91
- examples/integration_test.py <kafka-broker>
91
+ $ examples/integration_test.py <kafka-broker>
92
92
93
93
** WARNING** : These tests require an active Kafka cluster and will make use of a topic named 'test'.
94
94
@@ -99,13 +99,10 @@ Generate documentation
99
99
======================
100
100
Install sphinx and sphinx_rtd_theme packages and then:
101
101
102
- make docs
102
+ $ make docs
103
103
104
104
or:
105
105
106
- python setup.by build_sphinx
107
-
108
-
109
- Documentation will be generated in ` docs/_build/ `
110
-
106
+ $ python setup.by build_sphinx
111
107
108
+ Documentation will be generated in ` docs/_build/ ` .
0 commit comments