Skip to content

Synchronized old 0.8 branch with master and Kafka 0.8.0-beta1 #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 93 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
eff8d2b
Fixes #14
mumrah Apr 11, 2013
6327ba3
Update README.md
mumrah May 8, 2013
38215b6
New API for checking pending message count
mahendra May 27, 2013
117c576
New API for getting a specified set of messages
mahendra May 27, 2013
7ab7690
Missed a doc string
mahendra May 27, 2013
8fc0407
Auto commit timer is not periodic
mahendra May 28, 2013
904157b
Merge pull request #23 from mahendra/autocommit
mumrah May 28, 2013
bf8fc04
Adding a debug statement
mumrah Apr 12, 2013
f4a326f
Closes #22
mumrah May 28, 2013
222ef82
Merge branch 'issue-22'
mumrah May 28, 2013
a8e423c
Minor bug fixes
mahendra May 27, 2013
97962d4
Removing the bit about offsets
mumrah May 29, 2013
2c257ee
PEP8-ify most of the files
mahendra May 29, 2013
d0cb38c
Adding authors file
mumrah Jun 1, 2013
58288d9
Updating authors with links to github profiles
mumrah Jun 1, 2013
437889d
Fix auto-commit issues with multi-threading
mahendra Jun 3, 2013
6704050
Finish making remaining files pep8 ready
mahendra May 31, 2013
e073b33
Refactor and update integration tests
sandello Jun 1, 2013
f444caa
Adhere to common python naming conventions
sandello Jun 1, 2013
d7178e1
Beautify codec.py
sandello Jun 1, 2013
2bd2dbc
Split fixtures out to a separate file
sandello Jun 2, 2013
60200c6
toxify all the tests and use xfail marks
sandello Jun 2, 2013
800a512
Update README.md
sandello Jun 2, 2013
bdad6a1
Ignore MANIFEST
sandello Jun 2, 2013
4990381
Use 127.0.0.1 instead of localhost
sandello Jun 2, 2013
dd109e2
Bootstrap distribute/tox with setuptools
mumrah Jun 8, 2013
40506c2
Merge branch 'issue-28'
mumrah Jun 8, 2013
77b8301
Merge pull request #29 from mahendra/threading
mumrah Jun 10, 2013
a4601d3
Spawn the commit thread only if necessary
mahendra Jun 11, 2013
b0c87ee
Optimize auto-commit thread
mahendra Jun 12, 2013
28884c8
Fix an issue with thread argument
mahendra Jun 12, 2013
ab72da3
Add support to consume messages from specific partitions
mahendra Jun 12, 2013
b2a6503
Implement support for Keyed producer
mahendra Jun 13, 2013
ac76520
Fix markup in README
mahendra Jun 13, 2013
d3cf18a
Fix bugs and testing
mahendra Jun 13, 2013
0723cf8
Better examples in README
mahendra Jun 13, 2013
337127a
Support for async producer
mahendra Jun 13, 2013
883eed1
Merge pull request #32 from mahendra/keyed
mumrah Jun 13, 2013
604d78b
Merge branch 'master' into asyncproducer
mahendra Jun 13, 2013
aec3884
Merge branch 'master' into partition
mahendra Jun 20, 2013
c2c5557
Add ack support for synchronous producer
mahendra Jun 20, 2013
6158e29
Update README with new options
mahendra Jun 20, 2013
612dea1
Fix import errors
mahendra Jun 20, 2013
e690b75
Make the default case as 'ack on local write'
mahendra Jun 20, 2013
eee55ae
Add exports in __init__
mahendra Jun 24, 2013
b578725
Add support for multi-process consumer
mahendra Jun 24, 2013
e85190e
Minor bug fix
mahendra Jun 24, 2013
c7dfeba
Added more documentation and clean up duplicate code
mahendra Jun 25, 2013
2e38a52
Added the modules in __init__.py
mahendra Jun 25, 2013
119d411
Merge branch 'master' into lazythread
mahendra Jun 25, 2013
b022be2
Implement blocking get_messages for SimpleConsumer
mahendra Jun 25, 2013
99da57f
Added some comments about message state
mahendra Jun 25, 2013
65c8eb1
Got MultiProcessConsumer working
mahendra Jun 25, 2013
64b7578
Merge pull request #31 from mahendra/lazythread
mumrah Jun 25, 2013
ec251ef
Merge branch 'master' into asyncproducer
mahendra Jun 25, 2013
2ce3217
Merge branch 'master' into partition
mahendra Jun 25, 2013
7a5eed9
Change auto_commit to False in SimpleConsumer
mumrah Jun 25, 2013
b224f28
Fixing link in CHANGES.md
mumrah Jun 25, 2013
efb1dab
Add support for batched message send
mahendra Jun 26, 2013
0c0e163
Update README with examples
mahendra Jun 26, 2013
c6626fe
Make README self-containing
mahendra Jun 26, 2013
8b25625
Got batched mode to work properly
mahendra Jun 26, 2013
7f150a2
Optimize sending of batch messages
mahendra Jun 26, 2013
ffdc08a
Adding @sandello to AUTHORS.md
mumrah Jun 26, 2013
d2df8f5
Test cases for new producer
mahendra Jun 27, 2013
d6d7299
Fix a bug in seek.
mahendra Jun 27, 2013
b3fece5
Re-init the sockets in the new process
mahendra Jun 27, 2013
36b5f81
Test cases for multi-process consumer and blocking APIs
mahendra Jun 27, 2013
c2a49c1
Add TODO comments
mahendra Jun 27, 2013
6b76d9d
Fix markup in README
mahendra Jun 28, 2013
9a557ed
Fix markups
mahendra Jun 28, 2013
7b2a08f
Minor markup fix
mahendra Jun 28, 2013
c13ee1d
Fix cases of single partition
mahendra Jun 28, 2013
c54a2ed
Add more cleanup in consumer.stop()
mahendra Jun 28, 2013
1d278f0
Fix minor bug in offset management
mahendra Jul 1, 2013
5684af4
Merge pull request #33 from mahendra/asyncproducer
mumrah Jul 11, 2013
e297a7a
Merge branch 'issue-35'
mumrah Jul 26, 2013
c3bce13
Show alternative way of running tests in README.md
mumrah Jul 26, 2013
40d8e9e
Fixed #42, make fetch size configurable
mumrah Sep 9, 2013
f67ad27
Auto-adjusting consumer fetch size
mumrah Sep 9, 2013
0c732ca
Documenting new behavior in CHANGES.md
mumrah Sep 9, 2013
caf7c68
allow a client id to be passed to the client
Sep 24, 2013
9af7b81
Merge pull request #45 from quixey/allow-client-id
mumrah Sep 24, 2013
c0d2cac
Fix #44 Add missing exception class
mumrah Sep 25, 2013
3e68f94
Update README.md
StevenLeRoux Sep 26, 2013
2f6bcc2
Merge pull request #47 from StevenLeRoux/master
mahendra Sep 26, 2013
3194d55
Update README.md
StevenLeRoux Sep 26, 2013
2ed7638
Merge pull request #48 from StevenLeRoux/master
mumrah Sep 26, 2013
f81d254
import bufferunderflow error
Sep 27, 2013
c1a6b8e
Merge pull request #49 from jimjh/import-buffer-underflow-error
mumrah Sep 27, 2013
d640ddf
merged from master c1a6b8ebdb05e01e39f73d831c73cd5d624764c9
mrtheb Oct 1, 2013
8b9c7e5
Sync tests and fixtures with kafka 0.8.0-beta1 tag
mrtheb Oct 1, 2013
2b016b6
Set FetchRequest MaxBytes value to bufsize instead of fetchsize (=Min…
mrtheb Oct 1, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
*.egg-info
*.pyc
.tox
build
dist
MANIFEST
env
11 changes: 11 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Contributors

Ordered by contribution

* David Arthur, [@mumrah](https://github.com/mumrah)
* Mahendra M, [@mahendra](https://github.com/mahendra)
* Ivan Pouzyrevsky, [@sandello](https://github.com/sandello)
* [@anentropic](https://github.com/anentropic)
* Ben Frederickson, [@benfred](https://github.com/benfred)

Thanks, everyone!
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Notable Changes

* Changing auto_commit to False in [SimpleConsumer](kafka/consumer.py), until 0.8.1 is release offset commits are unsupported

* Adding fetch_size_bytes to SimpleConsumer constructor to allow for user-configurable fetch sizes

* Allow SimpleConsumer to automatically increase the fetch size if a partial message is read and no other messages were read during that fetch request. The increase factor is 1.5

* Exception classes moved to kafka.common
98 changes: 87 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Copyright 2013, David Arthur under Apache License, v2.0. See `LICENSE`

# Status

I'm following the version numbers of Kafka, plus one number to indicate the
I'm following the version numbers of Kafka, plus one number to indicate the
version of this project. The current version is 0.8.0-1. This version is under
development, APIs are subject to change.

Expand All @@ -26,21 +26,90 @@ development, APIs are subject to change.
```python
from kafka.client import KafkaClient
from kafka.consumer import SimpleConsumer
from kafka.producer import SimpleProducer
from kafka.producer import SimpleProducer, KeyedProducer

kafka = KafkaClient("localhost", 9092)

# To send messages synchronously
producer = SimpleProducer(kafka, "my-topic")
producer.send_messages("some message")
producer.send_messages("this method", "is variadic")

# To send messages asynchronously
producer = SimpleProducer(kafka, "my-topic", async=True)
producer.send_messages("async message")

# To wait for acknowledgements
# ACK_AFTER_LOCAL_WRITE : server will wait till the data is written to
# a local log before sending response
# ACK_AFTER_CLUSTER_COMMIT : server will block until the message is committed
# by all in sync replicas before sending a response
producer = SimpleProducer(kafka, "my-topic", async=False,
req_acks=SimpleProducer.ACK_AFTER_LOCAL_WRITE,
acks_timeout=2000)

response = producer.send_messages("async message")

if response:
print(response[0].error)
print(response[0].offset)

# To send messages in batch. You can use any of the available
# producers for doing this. The following producer will collect
# messages in batch and send them to Kafka after 20 messages are
# collected or every 60 seconds
# Notes:
# * If the producer dies before the messages are sent, there will be losses
# * Call producer.stop() to send the messages and cleanup
producer = SimpleProducer(kafka, "my-topic", batch_send=True,
batch_send_every_n=20,
batch_send_every_t=60)

# To consume messages
consumer = SimpleConsumer(kafka, "my-group", "my-topic")
for message in consumer:
print(message)

kafka.close()
```

## Keyed messages
```python
from kafka.client import KafkaClient
from kafka.producer import KeyedProducer
from kafka.partitioner import HashedPartitioner, RoundRobinPartitioner

kafka = KafkaClient("localhost", 9092)

# HashedPartitioner is default
producer = KeyedProducer(kafka, "my-topic")
producer.send("key1", "some message")
producer.send("key2", "this methode")

producer = KeyedProducer(kafka, "my-topic", partitioner=RoundRobinPartitioner)
```

## Multiprocess consumer
```python
from kafka.client import KafkaClient
from kafka.consumer import MultiProcessConsumer

kafka = KafkaClient("localhost", 9092)

# This will split the number of partitions among two processes
consumer = MultiProcessConsumer(kafka, "my-group", "my-topic", num_procs=2)

# This will spawn processes such that each handles 2 partitions max
consumer = MultiProcessConsumer(kafka, "my-group", "my-topic",
partitions_per_proc=2)

for message in consumer:
print(message)

for message in consumer.get_messages(count=5, block=True, timeout=4):
print(message)
```

## Low level

```python
Expand Down Expand Up @@ -101,16 +170,18 @@ pip install python-snappy

# Tests

Some of the tests will fail if Snappy is not installed. These tests will throw
NotImplementedError. If you see other failures, they might be bugs - so please
report them!

## Run the unit tests

_These are broken at the moment_

```shell
python -m test.unit
tox ./test/test_unit.py
```

or

```shell
python -m test.test_unit
```

## Run the integration tests
Expand All @@ -123,13 +194,18 @@ git submodule update
cd kafka-src
./sbt update
./sbt package
./sbt assembly-package-dependency
```

Next start up a ZooKeeper server on localhost:2181
And then run the tests. This will actually start up real local Zookeeper
instance and Kafka brokers, and send messages in using the client.

```shell
/opt/zookeeper/bin/zkServer.sh start
tox ./test/test_integration.py
```

This will actually start up real Kafka brokers and send messages in using the
client.
or

```shell
python -m test.test_integration
```
2 changes: 1 addition & 1 deletion kafka-src
Submodule kafka-src updated 140 files
13 changes: 8 additions & 5 deletions kafka/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
__license__ = 'Apache License 2.0'
__copyright__ = 'Copyright 2012, David Arthur under Apache License, v2.0'

from kafka.client import KafkaClient
from kafka.client import KafkaClient
from kafka.conn import KafkaConnection
from kafka.protocol import (
create_message, create_gzip_message, create_snappy_message
)
from kafka.producer import SimpleProducer
from kafka.consumer import SimpleConsumer
from kafka.producer import SimpleProducer, KeyedProducer
from kafka.partitioner import RoundRobinPartitioner, HashedPartitioner
from kafka.consumer import SimpleConsumer, MultiProcessConsumer

__all__ = [
'KafkaClient', 'KafkaConnection', 'SimpleProducer', 'SimpleConsumer',
'create_message', 'create_gzip_message', 'create_snappy_message'
'KafkaClient', 'KafkaConnection', 'SimpleProducer', 'KeyedProducer',
'RoundRobinPartitioner', 'HashedPartitioner', 'SimpleConsumer',
'MultiProcessConsumer', 'create_message', 'create_gzip_message',
'create_snappy_message'
]
Loading