|
1 | 1 | kafka-python
|
2 |
| -============ |
| 2 | +############ |
3 | 3 |
|
4 |
| -This module provides low-level protocol support for Apache Kafka as well as |
5 |
| -high-level consumer and producer classes. Request batching is supported by the |
6 |
| -protocol as well as broker-aware request routing. Gzip and Snappy compression |
7 |
| -is also supported for message sets. |
| 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 |
| 11 | + :target: https://travis-ci.org/dpkp/kafka-python |
| 12 | +.. image:: https://img.shields.io/badge/license-Apache%202-blue.svg |
| 13 | + :target: https://github.com/dpkp/kafka-python/blob/master/LICENSE |
8 | 14 |
|
9 |
| -Coordinated Consumer Group support is under development - see Issue #38. |
| 15 | +>>> pip install kafka-python |
10 | 16 |
|
11 |
| -On Freenode IRC at #kafka-python, as well as #apache-kafka |
| 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). |
12 | 20 |
|
13 |
| -For general discussion of kafka-client design and implementation (not python specific), |
14 |
| -see https://groups.google.com/forum/m/#!forum/kafka-clients |
15 | 21 |
|
16 |
| -For information about Apache Kafka generally, see https://kafka.apache.org/ |
| 22 | +KafkaConsumer |
| 23 | +************* |
17 | 24 |
|
18 |
| -Status |
19 |
| ------- |
| 25 | +>>> from kafka import KafkaConsumer |
| 26 | +>>> consumer = KafkaConsumer('my_favorite_topic') |
| 27 | +>>> for msg in consumer: |
| 28 | +... print (msg) |
20 | 29 |
|
21 |
| -The current stable version of this package is `0.9.5 <https://github.com/dpkp/kafka-python/releases/tag/v0.9.5>`_ and is compatible with: |
| 30 | +:class:`~kafka.consumer.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. |
22 | 35 |
|
23 |
| -Kafka broker versions |
| 36 | +In addition to the standard |
| 37 | +:meth:`~kafka.consumer.KafkaConsumer.poll` interface (which returns |
| 38 | +micro-batches of messages, grouped by topic-partition), kafka-python supports |
| 39 | +single-message iteration, yielding :class:`~kafka.consumer.ConsumerRecord` |
| 40 | +namedtuples, which include the topic, partition, offset, key, and value of each |
| 41 | +message. |
24 | 42 |
|
25 |
| -* 0.9.0.0 |
26 |
| -* 0.8.2.2 |
27 |
| -* 0.8.2.1 |
28 |
| -* 0.8.1.1 |
29 |
| -* 0.8.1 |
30 |
| -* 0.8.0 |
| 43 | +By default, :class:`~kafka.consumer.KafkaConsumer` will attempt to auto-commit |
| 44 | +message offsets every 5 seconds. When used with 0.9 kafka brokers, |
| 45 | +:class:`~kafka.consumer.KafkaConsumer` will dynamically assign partitions using |
| 46 | +the kafka GroupCoordinator APIs and a |
| 47 | +:class:`~kafka.coordinator.assignors.roundrobin.RoundRobinPartitionAssignor` |
| 48 | +partitioning strategy, enabling relatively straightforward parallel consumption |
| 49 | +patterns. See :doc:`usage` for examples. |
31 | 50 |
|
32 |
| -Python versions |
33 | 51 |
|
34 |
| -* 3.5 (tested on 3.5.0) |
35 |
| -* 3.4 (tested on 3.4.2) |
36 |
| -* 3.3 (tested on 3.3.5) |
37 |
| -* 2.7 (tested on 2.7.9) |
38 |
| -* 2.6 (tested on 2.6.9) |
39 |
| -* pypy (tested on pypy 2.5.0 / python 2.7.8) |
| 52 | +KafkaProducer |
| 53 | +************* |
40 | 54 |
|
41 |
| -License |
42 |
| -------- |
| 55 | +TBD |
43 | 56 |
|
44 |
| -Apache License, v2.0. See `LICENSE <https://github.com/dpkp/kafka-python/blob/master/LICENSE>`_. |
45 | 57 |
|
46 |
| -Copyright 2015, David Arthur, Dana Powers, and Contributors |
47 |
| -(See `AUTHORS <https://github.com/dpkp/kafka-python/blob/master/AUTHORS.md>`_). |
| 58 | +Protocol |
| 59 | +******** |
48 | 60 |
|
| 61 | +A secondary goal of kafka-python is to provide an easy-to-use protocol layer |
| 62 | +for interacting with kafka brokers via the python repl. This is useful for |
| 63 | +testing, probing, and general experimentation. The protocol support is |
| 64 | +leveraged to enable a :meth:`~kafka.KafkaClient.check_version()` |
| 65 | +method that probes a kafka broker and |
| 66 | +attempts to identify which version it is running (0.8.0 to 0.9). |
| 67 | + |
| 68 | + |
| 69 | +Low-level |
| 70 | +********* |
| 71 | + |
| 72 | +Legacy support is maintained for low-level consumer and producer classes, |
| 73 | +SimpleConsumer and SimpleProducer. |
49 | 74 |
|
50 |
| -Contents |
51 |
| --------- |
52 | 75 |
|
53 | 76 | .. toctree::
|
| 77 | + :hidden: |
54 | 78 | :maxdepth: 2
|
55 | 79 |
|
56 |
| - usage |
| 80 | + Usage Overview <usage> |
| 81 | + API </apidoc/modules> |
57 | 82 | install
|
58 | 83 | tests
|
59 |
| - API reference </apidoc/modules> |
60 |
| - |
61 |
| -Indices and tables |
62 |
| -================== |
63 |
| - |
64 |
| -* :ref:`genindex` |
65 |
| -* :ref:`modindex` |
66 |
| -* :ref:`search` |
| 84 | + compatibility |
| 85 | + support |
| 86 | + license |
0 commit comments