forked from confluentinc/librdkafka
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracted rdkafka from librd to its own library.
- Loading branch information
Showing
25 changed files
with
3,694 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
( (c-mode . ((c-file-style . "linux"))) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*~ | ||
\#* | ||
*.o | ||
*.so | ||
*.so.? | ||
*.a | ||
*.d | ||
core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
librdkafka - Apache Kafka C driver library | ||
|
||
Copyright (c) 2012, Magnus Edenhill | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
The following license applies to the files rdcrc32.c and rdcrc32.h which | ||
have been generated by the pycrc tool. | ||
============================================================================ | ||
|
||
Copyright (c) 2006-2012, Thomas Pircher <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
|
||
LIBNAME=librdkafka | ||
LIBVER=0 | ||
LIBVER_FULL=$(LIBVER).0.0 | ||
|
||
|
||
PREFIX?=/usr/local | ||
|
||
# The preferred way to compile is to have a separate checkout of librd | ||
# and link with it. If that is not desirable or possible the required librd | ||
# functionality is included with librdkafka for compile-time inclusion. | ||
# Define WITH_LIBRD to use an external librd, or leave undefined for the | ||
# integrated version. | ||
#WITH_LIBRD=1 | ||
|
||
# Use gcc as ld to avoid __stack_chk_fail_error symbol error. | ||
LD=gcc | ||
|
||
|
||
SRCS= rdkafka.c | ||
|
||
ifndef WITH_LIBRD | ||
SRCS+=rdcrc32.c rdgz.c rdaddr.c rdrand.c rdfile.c | ||
endif | ||
|
||
HDRS= rdkafka.h | ||
|
||
OBJS= $(SRCS:.c=.o) | ||
DEPS= ${OBJS:%.o=%.d} | ||
|
||
CFLAGS+=-O2 -Wall -Werror -Wfloat-equal -Wpointer-arith -fPIC -I. | ||
CFLAGS+=-g | ||
|
||
# Profiling | ||
#CFLAGS+=-O0 | ||
#CFLAGS += -pg | ||
#LDFLAGS += -pg | ||
|
||
LDFLAGS+=-shared -g -fPIC -lpthread -lrt -lz -lc | ||
|
||
.PHONY: | ||
|
||
all: libs | ||
|
||
libs: $(LIBNAME).so $(LIBNAME).a | ||
|
||
%.o: %.c | ||
$(CC) -MD -MP $(CFLAGS) -c $< | ||
|
||
$(LIBNAME).so: $(OBJS) | ||
$(LD) -shared -Wl,-soname,$(LIBNAME).so.$(LIBVER) \ | ||
$(LDFLAGS) $(OBJS) -o $@ | ||
ln -fs $(LIBNAME).so $(LIBNAME).so.$(LIBVER) | ||
|
||
$(LIBNAME).a: $(OBJS) | ||
$(AR) rcs $@ $(OBJS) | ||
|
||
install: | ||
install -d $(PREFIX)/include/librdkafka $(PREFIX)/lib | ||
install -t $(PREFIX)/include/$(LIBNAME) $(HDRS) | ||
install -t $(PREFIX)/lib $(LIBNAME).so | ||
install -t $(PREFIX)/lib $(LIBNAME).so.$(LIBVER) | ||
install -t $(PREFIX)/lib $(LIBNAME).a | ||
|
||
clean: | ||
rm -f $(OBJS) $(DEPS) $(LIBNAME)*.a $(LIBNAME)*.so $(LIBNAME)*.so.? | ||
|
||
-include $(DEPS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,72 @@ | ||
librdkafka | ||
========== | ||
librdkafka - Apache Kafka C client library | ||
========================================== | ||
|
||
Copyright (c) 2012, [Magnus Edenhill](http://www.edenhill.se/), et.al. | ||
|
||
[https://github.com/edenhill/librdkafka](https://github.com/edenhill/librdkafka) | ||
|
||
**librdkafka** is a C implementation of the | ||
[Apache Kafka](http://incubator.apache.org/kafka/) protocol, containing both | ||
Producer and Consumer support. | ||
It currently supports Apache Kafka version 0.7.* (and possibly earlier). | ||
|
||
ZooKeeper integration is planned but currently not available. | ||
|
||
**librdkafka** is licensed under the 2-clause BSD license. | ||
|
||
|
||
# Usage | ||
|
||
## Requirements | ||
The GNU toolchain | ||
pthreads | ||
zlib | ||
|
||
## Instructions | ||
|
||
### Building | ||
|
||
make all | ||
make install | ||
# or to install in another location than /usr/local: | ||
PREFIX=/my/prefix make install | ||
|
||
|
||
### Usage in code | ||
|
||
See `examples/rdkafka_example.c` for full examples of both | ||
producer and consumer sides. | ||
|
||
|
||
#include <librdkafka/rdkafka.h> | ||
|
||
.. | ||
|
||
rd_kafka_t *rk; | ||
|
||
rk = rd_kafka_new_consumer(broker, topic, partition, 0, &conf) | ||
|
||
while (run) { | ||
rko = rd_kafka_consume(rk, RD_POLL_INFINITE); | ||
if (rko->rko_err) | ||
..errhandling.. | ||
else if (rko->rko_len) | ||
handle_message(rko->rko_payload, rko->rko_len); | ||
} | ||
|
||
rd_kafka_destroy(rk); | ||
|
||
|
||
|
||
Link your program with `-lrdkafka -lz -lpthread -lrt`. | ||
|
||
|
||
## Documentation | ||
|
||
The API is documented in `rdkafka.h` | ||
|
||
## Examples | ||
|
||
See the `examples/`sub-directory. | ||
|
||
|
||
Apache Kafka C library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rdkafka_example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
CC ?= cc | ||
CFLAGS += -g | ||
CFLAGS += -Wall -Werror -Wfloat-equal -Wpointer-arith -O2 -I../ | ||
LDFLAGS += -L../ -lrdkafka | ||
LDFLAGS += -lpthread -lrt -lz | ||
|
||
# Profiling | ||
#CFLAGS += -O0 -pg | ||
#LDFLAGS += -pg | ||
|
||
all: | ||
@echo "# Examples are built individually, i.e.:" | ||
@echo " make rdkafka_example" | ||
|
||
|
||
rdkafka_example: rdkafka_example.c | ||
@(test $@ -nt $< || \ | ||
$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)) | ||
@echo "# $@ is ready" | ||
@echo "#" | ||
@echo "# Run producer (write messages on stdin)" | ||
@echo "LD_LIBRARY_PATH=../ ./rdkafka_example -P -t <topic> -p <partition>" | ||
@echo "" | ||
@echo "# or consumer" | ||
@echo "LD_LIBRARY_PATH=../ ./rdkafka_example -C -t <topic> -p <partition>" | ||
@echo "" | ||
@echo "#" | ||
@echo "# More usage options:" | ||
@echo "LD_LIBRARY_PATH=../ ./rdkafka_example --help" | ||
|
||
|
||
clean: | ||
rm -f rdkafka_example |
Oops, something went wrong.