Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ sudo: required
node_js:
- '4'
- '6'
env:
- WITH_SASL=0
- WITH_SASL=1
cache:
directories:
- node_modules
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This project includes two types of unit tests in this project:

You can run both types of tests by using `Makefile`. Doing so calls `mocha` in your locally installed `node_modules` directory.

* Before you run the tests, be sure to init and update the submodules:
* Before you run the tests, be sure to init and update the submodules:
1. `git submodule init`
2. `git submodule update`
* To run the unit tests, you can run `make lint` or `make test`.
Expand All @@ -62,7 +62,7 @@ var Kafka = require('node-rdkafka');

## Configuration

You can pass many configuration options to `librdkafka`. A full list can be found in `librdkafka`'s [Configuration.md](https://github.com/edenhill/librdkafka/blob/2213fb29f98a7a73f22da21ef85e0783f6fd67c4/CONFIGURATION.md)
You can pass many configuration options to `librdkafka`. A full list can be found in `librdkafka`'s [Configuration.md](https://github.com/edenhill/librdkafka/blob/2213fb29f98a7a73f22da21ef85e0783f6fd67c4/CONFIGURATION.md)

Configuration keys that have the suffix `_cb` are designated as callbacks. Some
of these keys are informational and you can choose to opt-in (for example, `dr_cb`). Others are callbacks designed to
Expand All @@ -76,6 +76,13 @@ The library currently supports the following callbacks:
* `dr_cb`
* `event_cb`

### SASL Support

`librdkafka` supports using SASL for authentication and `node-rdkafka` has it turned on by default. If you would like
disable `sasl` support, export `WITH_SASL=0` before you run `npm install`. (You can also specify it when using `node-gyp`, `node-gyp --WITH_SASL=0 rebuild`)

This means you are required to have `libsasl2` on the machine before you build it.

## Sending Messages

A `Producer` sends messages to Kafka. The `Producer` constructor takes a configuration object, as shown in the following example:
Expand Down
16 changes: 16 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"variables": {
# may be redefined in command line on configuration stage
"BUILD_LIBRDKAFKA%": "<!(echo ${BUILD_LIBRDKAFKA:-1})",
"WITH_SASL%": "<!(echo ${WITH_SASL:-1})"
},
"targets": [
{
Expand All @@ -11,6 +12,7 @@
"<!(node -e \"require('nan')\")",
"<(module_root_dir)/"
],
"libraries" : ['-lsasl2'],
'conditions': [
[ "<(BUILD_LIBRDKAFKA)==1",
{
Expand Down Expand Up @@ -62,6 +64,20 @@
},
}
],
[ "<(WITH_SASL)==1",
{
'libraries' : ['-lsasl2'],
'conditions': [
[ 'OS=="mac"',
{
'xcode_settings': {
'libraries' : ['-lsasl2']
}
}
],
]
}
]
]
}
]
Expand Down
34 changes: 26 additions & 8 deletions deps/librdkafka.gyp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
'variables': {
"WITH_SASL%": "<!(echo ${WITH_SASL:-1})"
},
'targets': [
{
"target_name": "librdkafka_cpp",
Expand Down Expand Up @@ -123,6 +126,13 @@
}
},
}
],
[ "<(WITH_SASL)==1",
{
'sources': [
'librdkafka/src/rdkafka_sasl.c'
]
}
]
],
'sources': [
Expand Down Expand Up @@ -171,14 +181,22 @@
'librdkafka/config.h',
],
"conditions": [
[
'OS!="win"',
{
'action': ['eval', 'cd librdkafka && chmod a+x ./configure && ./configure --disable-sasl']
},
{
'action': ['echo']
}
[ 'OS!="win"',
{
"conditions": [
[ "<(WITH_SASL)==1",
{
'action': ['eval', 'cd librdkafka && chmod a+x ./configure && ./configure']
},
{
'action': ['eval', 'cd librdkafka && chmod a+x ./configure && ./configure --disable-sasl']
}
]
]
},
{
'action': ['echo']
}
]
]
}
Expand Down