UNKNOWN
Project description
# pykafka
pykafka allows you to produce messages to the Kafka distributed publish/subscribe messaging service.
## Requirements
You need to have access to your Kafka instance and be able to connect through TCP. You can obtain a copy and instructions on how to setup kafka at https://github.com/kafka-dev/kafka
## Installation pip install pykafka
## Usage
### Sending a simple message
import kafka
producer = kafka.producer.Producer(‘test’) message = kafka.message.Message(“Foo!”) producer.send(message)
### Sending a sequence of messages
import kafka
producer = kafka.producer.Producer(‘test’) message1 = kafka.message.Message(“Foo!”) message2 = kafka.message.Message(“Bar!”) producer.send([message1, message2])
### Batching a bunch of messages using a context manager.
import kafka producer = kafka.producer.Producer(‘test’)
- with producer.batch() as messages:
print “Batching a send of multiple messages..” messages.append(kafka.message.Message(“first message to send”) messages.append(kafka.message.Message(“second message to send”)
they will be sent all at once, after the context manager execution.
### Consuming messages one by one
import kafka consumer = kafka.consumer.Consumer(‘test’) messages = consumer.consume()
### Consuming messages using a generator loop
import kafka
consumer = kafka.consumer.Consumer(‘test’)
- for message in consumer.loop():
print message
Contact:
Please use the GitHub issues: https://github.com/dsully/pykafka/issues
Inspiried from Alejandro Crosa’s kafka-rb: https://github.com/acrosa/kafka-rb
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pykafka-0.1.1.tar.gz
.
File metadata
- Download URL: pykafka-0.1.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6013949dc5f1881a6e408734310a8789fe54683b9e9ee1860951c2ea4c55d451 |
|
MD5 | eb6fb8c599047a566a1830798f38f6b3 |
|
BLAKE2b-256 | cdb1f31ddc6b99db6f0cc6f81a632b83b286b01aac6a06ba78f9e0f6ae9aee63 |