Skip to main content

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pykafka-0.1.2.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file pykafka-0.1.2.tar.gz.

File metadata

  • Download URL: pykafka-0.1.2.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pykafka-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a2ae273d0ab83c04225753fc7afc787156d01ae9d72a1d926a95fdf4de3a8a9e
MD5 2dd69d702f08282fbb320cefef0486e8
BLAKE2b-256 77e9b338288c77a13a28a17f21f756192b663b3576a0ca194f9a0366cb944623

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page