This repository has been archived by the owner on Jul 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathsetup.py
90 lines (60 loc) · 2.09 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python
"""
# 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
"""
import setuptools
# Don't install deps for development mode.
setuptools.bootstrap_install_from = None
setuptools.setup(
name = 'pykafka',
version = '0.1.3',
license = 'MIT',
long_description = __doc__,
author = "Dan Sully",
author_email = "[email protected]",
url = 'http://github.com/dsully/pykafka',
platforms = 'any',
# What are we packaging up?
packages = setuptools.find_packages('.'),
zip_safe = True,
verbose = False,
)