|
1 | 1 | Kafka Python client
|
2 | 2 | ------------------------
|
3 |
| -.. image:: https://api.travis-ci.org/dpkp/kafka-python.png?branch=master |
| 3 | + |
| 4 | +.. image:: https://img.shields.io/badge/kafka-0.9%2C%200.8.2%2C%200.8.1%2C%200.8-brightgreen.svg |
| 5 | + :target: https://kafka-python.readthedocs.org/compatibility.html |
| 6 | +.. image:: https://img.shields.io/pypi/pyversions/kafka-python.svg |
| 7 | + :target: https://pypi.python.org/pypi/kafka-python |
| 8 | +.. image:: https://coveralls.io/repos/dpkp/kafka-python/badge.svg?branch=master&service=github |
| 9 | + :target: https://coveralls.io/github/dpkp/kafka-python?branch=master |
| 10 | +.. image:: https://travis-ci.org/dpkp/kafka-python.svg?branch=master |
4 | 11 | :target: https://travis-ci.org/dpkp/kafka-python
|
5 |
| - :alt: Build Status |
| 12 | +.. image:: https://img.shields.io/badge/license-Apache%202-blue.svg |
| 13 | + :target: https://github.com/dpkp/kafka-python/blob/master/LICENSE |
| 14 | + |
| 15 | +>>> pip install kafka-python |
| 16 | + |
| 17 | +kafka-python is a client for the Apache Kafka distributed stream processing |
| 18 | +system. It is designed to function much like the official java client, with a |
| 19 | +sprinkling of pythonic interfaces (e.g., iterators). |
| 20 | + |
6 | 21 |
|
7 |
| -.. image:: https://coveralls.io/repos/dpkp/kafka-python/badge.svg?branch=master |
8 |
| - :target: https://coveralls.io/r/dpkp/kafka-python?branch=master |
9 |
| - :alt: Coverage Status |
| 22 | +KafkaConsumer |
| 23 | +************* |
10 | 24 |
|
11 |
| -.. image:: https://readthedocs.org/projects/kafka-python/badge/?version=latest |
12 |
| - :target: http://kafka-python.readthedocs.org/en/latest/ |
13 |
| - :alt: Full documentation available on ReadTheDocs |
| 25 | +>>> from kafka import KafkaConsumer |
| 26 | +>>> consumer = KafkaConsumer('my_favorite_topic') |
| 27 | +>>> for msg in consumer: |
| 28 | +... print (msg) |
14 | 29 |
|
15 |
| -This module provides low-level protocol support for Apache Kafka as well as |
16 |
| -high-level consumer and producer classes. Request batching is supported by the |
17 |
| -protocol as well as broker-aware request routing. Gzip and Snappy compression |
18 |
| -is also supported for message sets. |
| 30 | +KafkaConsumer is a full-featured, |
| 31 | +high-level message consumer class that is similar in design and function to the |
| 32 | +new 0.9 java consumer. Most configuration parameters defined by the official |
| 33 | +java client are supported as optional kwargs, with generally similar behavior. |
| 34 | +Gzip and Snappy compressed messages are supported transparently. |
19 | 35 |
|
20 |
| -Coordinated Consumer Group support is under development - see Issue #38. |
| 36 | +In addition to the standard KafkaConsumer.poll() interface (which returns |
| 37 | +micro-batches of messages, grouped by topic-partition), kafka-python supports |
| 38 | +single-message iteration, yielding ConsumerRecord namedtuples, which include |
| 39 | +the topic, partition, offset, key, and value of each message. |
21 | 40 |
|
22 |
| -Full documentation available on `Read the Docs <https://kafka-python.readthedocs.org/en/latest/>`_ |
| 41 | +By default, KafkaConsumer will attempt to auto-commit |
| 42 | +message offsets every 5 seconds. When used with 0.9 kafka brokers, |
| 43 | +KafkaConsumer will dynamically assign partitions using |
| 44 | +the kafka GroupCoordinator APIs and a RoundRobinPartitionAssignor |
| 45 | +partitioning strategy, enabling relatively straightforward parallel consumption |
| 46 | +patterns. See `ReadTheDocs <http://kafka-python.readthedocs.org/master/>`_ |
| 47 | +for examples. |
23 | 48 |
|
24 |
| -On Freenode IRC at #kafka-python, as well as #apache-kafka |
25 | 49 |
|
26 |
| -For general discussion of kafka-client design and implementation (not python specific), |
27 |
| -see https://groups.google.com/forum/#!forum/kafka-clients |
| 50 | +KafkaProducer |
| 51 | +************* |
28 | 52 |
|
29 |
| -For information about Apache Kafka generally, see https://kafka.apache.org/ |
| 53 | +<`in progress - see SimpleProducer for legacy producer implementation`> |
30 | 54 |
|
31 |
| -License |
32 |
| ----------- |
33 |
| -Apache License, v2.0. See `LICENSE <https://github.com/dpkp/kafka-python/blob/master/LICENSE>`_ |
34 |
| -Copyright 2015, David Arthur, Dana Powers, and Contributors |
35 |
| -(See `AUTHORS <https://github.com/dpkp/kafka-python/blob/master/AUTHORS.md>`_) |
36 | 55 |
|
37 |
| -Status |
38 |
| ----------- |
39 |
| -The current stable version of this package is |
40 |
| -`0.9.5 <https://github.com/dpkp/kafka-python/releases/tag/v0.9.5>`_ |
41 |
| -and is compatible with: |
| 56 | +Protocol |
| 57 | +******** |
42 | 58 |
|
43 |
| -Kafka broker versions |
| 59 | +A secondary goal of kafka-python is to provide an easy-to-use protocol layer |
| 60 | +for interacting with kafka brokers via the python repl. This is useful for |
| 61 | +testing, probing, and general experimentation. The protocol support is |
| 62 | +leveraged to enable a KafkaClient.check_version() method that |
| 63 | +probes a kafka broker and attempts to identify which version it is running |
| 64 | +(0.8.0 to 0.9). |
44 | 65 |
|
45 |
| -- 0.9.0.0 |
46 |
| -- 0.8.2.2 |
47 |
| -- 0.8.2.1 |
48 |
| -- 0.8.1.1 |
49 |
| -- 0.8.1 |
50 |
| -- 0.8.0 |
51 | 66 |
|
52 |
| -Python versions |
| 67 | +Low-level |
| 68 | +********* |
53 | 69 |
|
54 |
| -- 3.5 (tested on 3.5.0) |
55 |
| -- 3.4 (tested on 3.4.2) |
56 |
| -- 3.3 (tested on 3.3.5) |
57 |
| -- 2.7 (tested on 2.7.9) |
58 |
| -- 2.6 (tested on 2.6.9) |
59 |
| -- pypy (tested on pypy 2.5.0 / python 2.7.8) |
| 70 | +Legacy support is maintained for low-level consumer and producer classes, |
| 71 | +SimpleConsumer and SimpleProducer. See |
| 72 | +`ReadTheDocs <http://kafka-python.readthedocs.org/master/>`_ for API details. |
0 commit comments