Skip to content

Commit

Permalink
rename from pykafka to brod
Browse files Browse the repository at this point in the history
  • Loading branch information
David Ormsbee committed Nov 22, 2011
1 parent 0a2c12c commit e5dc170
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build
dist
*.egg-info
*.pyc
.DS_Store
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2011 Daniel Sully
Copyright (c) 2011 Datadog, Inc.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# pykafka
# brod

pykafka allows you to produce messages to the Kafka distributed publish/subscribe messaging service.
brod allows you to produce messages to the Kafka distributed publish/subscribe
messaging service. It started as a fork of pykafka
(https://github.com/dsully/pykafka), but became a total rewrite as we needed to
add many features.

It's named after Max Brod, Franz Kafka's friend and supporter.

## Requirements

Expand All @@ -9,27 +14,27 @@ TCP. You can obtain a copy and instructions on how to setup kafka at
https://github.com/kafka-dev/kafka

## Installation
easy_install -f 'https://github.com/DataDog/pykafka/tarball/2.1.0#egg=pykafka-2.1.0' pykafka
easy_install brod

## Usage

### Sending a simple message

import kafka
kafka = kafka.Kafka(host='localhost')
import brod
kafka = brod.Kafka(host='localhost')
kafka.produce("test-topic", "Hello World")

### Sending a sequence of messages

import kafka
kafka = kafka.Kafka(host='localhost')
import brod
kafka = brod.Kafka(host='localhost')
kafka.produce("test-topic", ["Hello", "World"])

### Consuming messages one by one

import kafka
kafka = kafka.Kafka(host='localhost')
for offset, message in kafka.fetch("test-topic", offset=0):
import brod
kafka = brod.Kafka(host='localhost')
for offset, message in brod.fetch("test-topic", offset=0):
print message

### Nonblocking Tornado client support
Expand All @@ -38,8 +43,8 @@ easy_install -f 'https://github.com/DataDog/pykafka/tarball/2.1.0#egg=pykafka-2.
import tornado.ioloop
import tornado.web

from kafka import LATEST_OFFSET
from kafka.nonblocking import KafkaTornado
from brod import LATEST_OFFSET
from brod.nonblocking import KafkaTornado

class MainHandler(tornado.web.RequestHandler):
def initialize(self, kafka, topic):
Expand All @@ -52,12 +57,12 @@ easy_install -f 'https://github.com/DataDog/pykafka/tarball/2.1.0#egg=pykafka-2.
@tornado.web.asynchronous
def get(self):
kafka.offsets(self.topic, LATEST_OFFSET, max_offsets=2,
brod.offsets(self.topic, LATEST_OFFSET, max_offsets=2,
callback=self._on_offset)

def _on_offset(self, offsets):
offset = offsets[-1] # Get the second to latest offset
kafka.fetch(self.topic, offset, callback=self._on_fetch)
brod.fetch(self.topic, offset, callback=self._on_fetch)

def _on_fetch(self, messages):
for offset, message in messages:
Expand All @@ -83,6 +88,6 @@ easy_install -f 'https://github.com/DataDog/pykafka/tarball/2.1.0#egg=pykafka-2.

Contact:

Please use the GitHub issues: https://github.com/datadog/pykafka/issues
Please use the GitHub issues: https://github.com/datadog/brod/issues

* Forked from https://github.com/dsully/pykafka which was inspired by Alejandro Crosa's kafka-rb: https://github.com/acrosa/kafka-rb
2 changes: 2 additions & 0 deletions brod/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from brod.base import *
from brod.blocking import *
File renamed without changes.
4 changes: 2 additions & 2 deletions kafka/blocking.py → brod/blocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import errno
import socket

from kafka.base import BaseKafka, logging, StringIO, ConnectionFailure
socket_log = logging.getLogger('kafka.socket')
from brod.base import BaseKafka, logging, StringIO, ConnectionFailure
socket_log = logging.getLogger('brod.socket')

__all__ = [
'Kafka',
Expand Down
4 changes: 2 additions & 2 deletions kafka/nonblocking.py → brod/nonblocking.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import array
import socket

from kafka.base import BaseKafka, logging, StringIO, ConnectionFailure
socket_log = logging.getLogger('kafka.iostream')
from brod.base import BaseKafka, logging, StringIO, ConnectionFailure
socket_log = logging.getLogger('brod.iostream')

from tornado.iostream import IOStream

Expand Down
2 changes: 0 additions & 2 deletions kafka/__init__.py

This file was deleted.

0 comments on commit e5dc170

Please sign in to comment.