Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Restructured: C bindings are now a submodule (cimpl)
  • Loading branch information
edenhill committed Apr 29, 2016
commit b2568b459d5195063862758dfee0e08ba12e88fe
2 changes: 2 additions & 0 deletions confluent_kafka/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__all__ = ['cimpl','kafkatest']
from .cimpl import *
2 changes: 1 addition & 1 deletion Consumer.c → confluent_kafka/cimpl/Consumer.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ static PyObject *Consumer_new (PyTypeObject *type, PyObject *args,

PyTypeObject ConsumerType = {
PyVarObject_HEAD_INIT(NULL, 0)
"confluent_kafka.Consumer", /*tp_name*/
"cimpl.Consumer", /*tp_name*/
sizeof(Consumer), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)Consumer_dealloc, /*tp_dealloc*/
Expand Down
2 changes: 1 addition & 1 deletion Producer.c → confluent_kafka/cimpl/Producer.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ static PyObject *Producer_new (PyTypeObject *type, PyObject *args,

PyTypeObject ProducerType = {
PyVarObject_HEAD_INIT(NULL, 0)
"confluent_kafka.Producer", /*tp_name*/
"cimpl.Producer", /*tp_name*/
sizeof(Producer), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)Producer_dealloc, /*tp_dealloc*/
Expand Down
36 changes: 18 additions & 18 deletions confluent_kafka.c → confluent_kafka/cimpl/confluent_kafka.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static PyObject* KafkaError_richcompare (KafkaError *self, PyObject *o2,

static PyTypeObject KafkaErrorType = {
PyVarObject_HEAD_INIT(NULL, 0)
"confluent_kafka.KafkaError", /*tp_name*/
"cimpl.KafkaError", /*tp_name*/
sizeof(KafkaError), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)KafkaError_dealloc, /*tp_dealloc*/
Expand Down Expand Up @@ -416,7 +416,7 @@ static PySequenceMethods Message_seq_methods = {

PyTypeObject MessageType = {
PyVarObject_HEAD_INIT(NULL, 0)
"confluent_kafka.Message", /*tp_name*/
"cimpl.Message", /*tp_name*/
sizeof(Message), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)Message_dealloc, /*tp_dealloc*/
Expand Down Expand Up @@ -660,7 +660,7 @@ static long TopicPartition_hash (TopicPartition *self) {

static PyTypeObject TopicPartitionType = {
PyVarObject_HEAD_INIT(NULL, 0)
"confluent_kafka.TopicPartition", /*tp_name*/
"cimpl.TopicPartition", /*tp_name*/
sizeof(TopicPartition), /*tp_basicsize*/
0, /*tp_itemsize*/
(destructor)TopicPartition_dealloc, /*tp_dealloc*/
Expand Down Expand Up @@ -772,7 +772,7 @@ rd_kafka_topic_partition_list_t *py_to_c_parts (PyObject *plist) {

if (!PyList_Check(plist)) {
PyErr_SetString(PyExc_TypeError,
"requires list of confluent_kafka.TopicPartition");
"requires list of TopicPartition");
return NULL;
}

Expand Down Expand Up @@ -1137,7 +1137,7 @@ static PyObject *version (PyObject *self, PyObject *args) {
return Py_BuildValue("si", "0.9.1", 0x00090100);
}

static PyMethodDef confluent_kafka_methods[] = {
static PyMethodDef cimpl_methods[] = {
{"libversion", libversion, METH_NOARGS,
" Retrieve librdkafka version string and integer\n"
"\n"
Expand Down Expand Up @@ -1230,17 +1230,17 @@ static char *KafkaError_add_errs (PyObject *dict, const char *origdoc) {


#ifdef PY3
static struct PyModuleDef confluent_kafka_moduledef = {
static struct PyModuleDef cimpl_moduledef = {
PyModuleDef_HEAD_INIT,
"confluent_kafka", /* m_name */
"Confluent's Apache Kafka Python client", /* m_doc */
"cimpl", /* m_name */
"Confluent's Apache Kafka Python client (C implementation)", /* m_doc */
-1, /* m_size */
confluent_kafka_methods, /* m_methods */
cimpl_methods, /* m_methods */
};
#endif


static PyObject *_init_confluent_kafka (void) {
static PyObject *_init_cimpl (void) {
PyObject *m;

if (PyType_Ready(&KafkaErrorType) < 0)
Expand All @@ -1255,10 +1255,10 @@ static PyObject *_init_confluent_kafka (void) {
return NULL;

#ifdef PY3
m = PyModule_Create(&confluent_kafka_moduledef);
m = PyModule_Create(&cimpl_moduledef);
#else
m = Py_InitModule3("confluent_kafka", confluent_kafka_methods,
"Confluent's Apache Kafka Python client");
m = Py_InitModule3("cimpl", cimpl_methods,
"Confluent's Apache Kafka Python client (C implementation)");
#endif
if (!m)
return NULL;
Expand All @@ -1283,7 +1283,7 @@ static PyObject *_init_confluent_kafka (void) {
PyModule_AddObject(m, "Consumer", (PyObject *)&ConsumerType);

KafkaException = PyErr_NewExceptionWithDoc(
"confluent_kafka.KafkaException",
"cimpl.KafkaException",
"Kafka exception that wraps the :py:class:`KafkaError` "
"class.\n"
"\n"
Expand All @@ -1299,11 +1299,11 @@ static PyObject *_init_confluent_kafka (void) {


#ifdef PY3
PyMODINIT_FUNC PyInit_confluent_kafka (void) {
return _init_confluent_kafka();
PyMODINIT_FUNC PyInit_cimpl (void) {
return _init_cimpl();
}
#else
PyMODINIT_FUNC initconfluent_kafka (void) {
_init_confluent_kafka();
PyMODINIT_FUNC initcimpl (void) {
_init_cimpl();
}
#endif
File renamed without changes.
43 changes: 43 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,49 @@ Indices and tables
:synopsis: Confluent's Apache Kafka Python client.
:members:

********
Consumer
********

.. autoclass:: confluent_kafka.Consumer
:members:

********
Producer
********

.. autoclass:: confluent_kafka.Producer
:members:

*******
Message
*******

.. autoclass:: confluent_kafka.Message
:members:

**************
TopicPartition
**************

.. autoclass:: confluent_kafka.TopicPartition
:members:

**********
KafkaError
**********

.. autoclass:: confluent_kafka.KafkaError
:members:

**************
KafkaException
**************

.. autoclass:: confluent_kafka.KafkaException
:members:



Configuration
=============
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
from distutils.core import Extension


module = Extension('confluent_kafka',
module = Extension('confluent_kafka.cimpl',
include_dirs = ['/usr/local/include'],
libraries= ['rdkafka'],
sources=['confluent_kafka.c', 'Producer.c', 'Consumer.c'])
sources=['confluent_kafka/cimpl/confluent_kafka.c', 'confluent_kafka/cimpl/Producer.c', 'confluent_kafka/cimpl/Consumer.c'])

setup (name='confluent-kafka',
version='0.9.1',
description='Confluent\'s Apache Kafka client for Python',
author='Confluent Inc',
author_email='[email protected]',
url='https://github.com/confluentinc/confluent-kafka-python',
ext_modules=[module])

ext_modules=[module],
packages=['confluent_kafka', 'confluent_kafka.cimpl', 'confluent_kafka.kafkatest'])