{ "info": { "author": "Dana Powers, Thai Pham", "author_email": "dana.powers@gmail.com,thaiphamquoc@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Kafka Python client\n------------------------\n\n.. image:: https://img.shields.io/badge/kafka-0.11%2C%200.10%2C%200.9%2C%200.8-brightgreen.svg\n :target: https://kafka-python.readthedocs.io/compatibility.html\n.. image:: https://img.shields.io/pypi/pyversions/kafka-python.svg\n :target: https://pypi.python.org/pypi/kafka-python\n.. image:: https://coveralls.io/repos/dpkp/kafka-python/badge.svg?branch=master&service=github\n :target: https://coveralls.io/github/dpkp/kafka-python?branch=master\n.. image:: https://travis-ci.org/dpkp/kafka-python.svg?branch=master\n :target: https://travis-ci.org/dpkp/kafka-python\n.. image:: https://img.shields.io/badge/license-Apache%202-blue.svg\n :target: https://github.com/dpkp/kafka-python/blob/master/LICENSE\n\nPython client for the Apache Kafka distributed stream processing system.\nkafka-python is designed to function much like the official java client, with a\nsprinkling of pythonic interfaces (e.g., consumer iterators).\n\nkafka-python is best used with newer brokers (0.9+), but is backwards-compatible with\nolder versions (to 0.8.0). Some features will only be enabled on newer brokers.\nFor example, fully coordinated consumer groups -- i.e., dynamic partition\nassignment to multiple consumers in the same group -- requires use of 0.9+ kafka\nbrokers. Supporting this feature for earlier broker releases would require\nwriting and maintaining custom leadership election and membership / health\ncheck code (perhaps using zookeeper or consul). For older brokers, you can\nachieve something similar by manually assigning different partitions to each\nconsumer instance with config management tools like chef, ansible, etc. This\napproach will work fine, though it does not support rebalancing on failures.\nSee \nfor more details.\n\nPlease note that the master branch may contain unreleased features. For release\ndocumentation, please see readthedocs and/or python's inline help.\n\n>>> pip install kafka-python\n\nKafkaConsumer\n*************\n\nKafkaConsumer is a high-level message consumer, intended to operate as similarly\nas possible to the official java client. Full support for coordinated\nconsumer groups requires use of kafka brokers that support the Group APIs: kafka v0.9+.\n\nSee \nfor API and configuration details.\n\nThe consumer iterator returns ConsumerRecords, which are simple namedtuples\nthat expose basic message attributes: topic, partition, offset, key, and value:\n\n>>> from kafka import KafkaConsumer\n>>> consumer = KafkaConsumer('my_favorite_topic')\n>>> for msg in consumer:\n... print (msg)\n\n>>> # join a consumer group for dynamic partition assignment and offset commits\n>>> from kafka import KafkaConsumer\n>>> consumer = KafkaConsumer('my_favorite_topic', group_id='my_favorite_group')\n>>> for msg in consumer:\n... print (msg)\n\n>>> # manually assign the partition list for the consumer\n>>> from kafka import TopicPartition\n>>> consumer = KafkaConsumer(bootstrap_servers='localhost:1234')\n>>> consumer.assign([TopicPartition('foobar', 2)])\n>>> msg = next(consumer)\n\n>>> # Deserialize msgpack-encoded values\n>>> consumer = KafkaConsumer(value_deserializer=msgpack.loads)\n>>> consumer.subscribe(['msgpackfoo'])\n>>> for msg in consumer:\n... assert isinstance(msg.value, dict)\n\n>>> # Get consumer metrics\n>>> metrics = consumer.metrics()\n\nKafkaProducer\n*************\n\nKafkaProducer is a high-level, asynchronous message producer. The class is\nintended to operate as similarly as possible to the official java client.\nSee \nfor more details.\n\n>>> from kafka import KafkaProducer\n>>> producer = KafkaProducer(bootstrap_servers='localhost:1234')\n>>> for _ in range(100):\n... producer.send('foobar', b'some_message_bytes')\n\n>>> # Block until a single message is sent (or timeout)\n>>> future = producer.send('foobar', b'another_message')\n>>> result = future.get(timeout=60)\n\n>>> # Block until all pending messages are at least put on the network\n>>> # NOTE: This does not guarantee delivery or success! It is really\n>>> # only useful if you configure internal batching using linger_ms\n>>> producer.flush()\n\n>>> # Use a key for hashed-partitioning\n>>> producer.send('foobar', key=b'foo', value=b'bar')\n\n>>> # Serialize json messages\n>>> import json\n>>> producer = KafkaProducer(value_serializer=lambda v: json.dumps(v).encode('utf-8'))\n>>> producer.send('fizzbuzz', {'foo': 'bar'})\n\n>>> # Serialize string keys\n>>> producer = KafkaProducer(key_serializer=str.encode)\n>>> producer.send('flipflap', key='ping', value=b'1234')\n\n>>> # Compress messages\n>>> producer = KafkaProducer(compression_type='gzip')\n>>> for i in range(1000):\n... producer.send('foobar', b'msg %d' % i)\n\n>>> # Get producer performance metrics\n>>> metrics = producer.metrics()\n\nThread safety\n*************\n\nThe KafkaProducer can be used across threads without issue, unlike the\nKafkaConsumer which cannot.\n\nWhile it is possible to use the KafkaConsumer in a thread-local manner,\nmultiprocessing is recommended.\n\nCompression\n***********\n\nkafka-python supports gzip compression/decompression natively. To produce or consume lz4\ncompressed messages, you should install python-lz4 (pip install lz4).\nTo enable snappy compression/decompression install python-snappy (also requires snappy library).\nSee \nfor more information.\n\nProtocol\n********\n\nA secondary goal of kafka-python is to provide an easy-to-use protocol layer\nfor interacting with kafka brokers via the python repl. This is useful for\ntesting, probing, and general experimentation. The protocol support is\nleveraged to enable a KafkaClient.check_version() method that\nprobes a kafka broker and attempts to identify which version it is running\n(0.8.0 to 0.11).\n\nLow-level\n*********\n\nLegacy support is maintained for low-level consumer and producer classes,\nSimpleConsumer and SimpleProducer. See\n for API details.\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/thaiphamquoc/kafka-python", "keywords": "apache kafka", "license": "Apache License 2.0", "maintainer": "", "maintainer_email": "", "name": "pyka", "package_url": "https://pypi.org/project/pyka/", "platform": "", "project_url": "https://pypi.org/project/pyka/", "project_urls": { "Homepage": "https://github.com/thaiphamquoc/kafka-python" }, "release_url": "https://pypi.org/project/pyka/1.3.6.0/", "requires_dist": null, "requires_python": "", "summary": "Pure Python client for Apache Kafka", "version": "1.3.6.0" }, "last_serial": 3522334, "releases": { "1.3.6.0": [ { "comment_text": "", "digests": { "md5": "515a0b47187e5179b918bf840b0e3c07", "sha256": "5eece24d22d936920a4c25776955f1627d272afc07c43f38f3c7b93d32d86ffe" }, "downloads": -1, "filename": "pyka-1.3.6.0.tar.gz", "has_sig": false, "md5_digest": "515a0b47187e5179b918bf840b0e3c07", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 246727, "upload_time": "2018-01-26T00:54:36", "url": "https://files.pythonhosted.org/packages/dd/1a/0eb1b48f270ebf513f7256d2195030de92ddcca875591ff4b2437b307f9a/pyka-1.3.6.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "515a0b47187e5179b918bf840b0e3c07", "sha256": "5eece24d22d936920a4c25776955f1627d272afc07c43f38f3c7b93d32d86ffe" }, "downloads": -1, "filename": "pyka-1.3.6.0.tar.gz", "has_sig": false, "md5_digest": "515a0b47187e5179b918bf840b0e3c07", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 246727, "upload_time": "2018-01-26T00:54:36", "url": "https://files.pythonhosted.org/packages/dd/1a/0eb1b48f270ebf513f7256d2195030de92ddcca875591ff4b2437b307f9a/pyka-1.3.6.0.tar.gz" } ] }