Skip to content

Commit

Permalink
Initial commit of node-rdkafka
Browse files Browse the repository at this point in the history
  • Loading branch information
webmakersteve committed Aug 11, 2016
0 parents commit 0edd0d4
Show file tree
Hide file tree
Showing 73 changed files with 15,441 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
@@ -0,0 +1,5 @@
[*]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
11 changes: 11 additions & 0 deletions .gitignore
@@ -0,0 +1,11 @@
build/
node_modules/
deps/librdkafka
npm-debug.log

docs

deps/*
!deps/*.gyp

.DS_Store
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "deps/librdkafka"]
path = deps/librdkafka
url = https://github.com/edenhill/librdkafka.git
1 change: 1 addition & 0 deletions .jshintignore
@@ -0,0 +1 @@
README.md
23 changes: 23 additions & 0 deletions .jshintrc
@@ -0,0 +1,23 @@
{
"node": true,
"mocha": true,
"browser": false,
"boss": true,
"curly": true,
"debug": false,
"devel": false,
"eqeqeq": true,
"evil": true,
"forin": false,
"latedef": false,
"noarg": true,
"nonew": true,
"nomen": false,
"onevar": false,
"plusplus": false,
"regexp": false,
"undef": true,
"strict": false,
"white": false,
"eqnull": true
}
6 changes: 6 additions & 0 deletions .npmignore
@@ -0,0 +1,6 @@
deps/
!deps/librdkafka.gyp
!deps/librdkafka
.gitmodules
Dockerfile
deps/librdkafka/config.h
20 changes: 20 additions & 0 deletions .travis.yml
@@ -0,0 +1,20 @@
dist: trusty
language: node_js
sudo: required
node_js:
- '4'
- '6'
cache:
directories:
- node_modules
services:
- docker
before_install:
- docker-compose up -d
script:
- make lint
- make test
- make e2e
after_success:
- make docs
- echo "Disallow: /" >> docs/robots.txt
5 changes: 5 additions & 0 deletions CHANGES.md
@@ -0,0 +1,5 @@
## Changelog

### 0.3.0

* Initial release!
158 changes: 158 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,158 @@
# Contributing to `node-rdkafka`

:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:

The following is a set of guidelines for contributing to `node-rdkafka`
which is hosted in the [Blizzard Organization](https://github.com/blizzard)
on GitHub. This document lists rules, guidelines, and help getting started,
so if you feel something is missing feel free to send a pull request.

#### Table Of Contents

[What should I know before I get started?](#what-should-i-know-before-i-get-started)
* [Contributor Agreement](#contributor-agreement)

[How Can I Contribute?](#how-can-i-contribute)
* [Reporting Bugs](#reporting-bugs)
* [Suggesting Enhancements](#suggesting-enhancements)
* [Pull Requests](#pull-requests)

[Styleguides](#styleguides)
* [Git Commit Messages](#git-commit-messages)
* [JavaScript Styleguide](#javascript-styleguide)
* [C++ Styleguide](#c++-styleguide)
* [Specs Styleguide](#specs-styleguide)
* [Documentation Styleguide](#documentation-styleguide)

[Debugging](#debugging)
* [Debugging C++](#debugging-c)

## What should I know before I get started?

### Contributor Agreement

Not currently required.

## How can I contribute?

### Reporting Bugs

Please use __Github Issues__ to report bugs. When filling out an issue report,
make sure to copy any related code and stack traces so we can properly debug.
We need to be able to reproduce a failing test to be able to fix your issue
most of the time, so a custom written failing test is very helpful.

Please also note the Kafka broker version that you are using and how many
replicas, partitions, and brokers you are connecting to, because some issues
might be related to Kafka. A list of `librdkafka` configuration key-value pairs
also helps.

### Suggesting Enhancements

Please use __Github Issues__ to suggest enhancements. We are happy to consider
any extra functionality or features to the library, as long as they add real
and related value to users. Describing your use case and why such an addition
helps the user base can help guide the decision to implement it into the
library's core.

### Pull Requests

* Include new test cases (either end-to-end or unit tests) with your change.
* Follow our style guides.
* Make sure all tests are still passing and the `linter` does not report any issues.
* End files with a new line.
* Document the new code in the comments (if it is JavaScript) so the
documentation generator can update the reference documentation.
* Avoid platform-dependent code.
<br>**Note:** If making modifications to the underlying C++, please use built-in
precompiler directives to detect such platform specificities. Use `Nan`
whenever possible to abstract node/v8 version incompatibility.
* Make sure your branch is up to date and rebased.
* Squash extraneous commits unless their history truly adds value to the library.

## Styleguides

### General style guidelines

Download the [EditorConfig](http://editorconfig.org) plugin for your preferred
text editor to automate the application of the following guidelines:

* Use 2-space indent (no tabs).
* Do not leave trailing whitespace on lines.
* Files should end with a final newline.

Also, adhere to the following not enforced by EditorConfig:

* Limit lines to 80 characters in length. A few extra (<= 5) is fine if it helps
readability, use good judgement.
* Use `lf` line endings. (git's `core.autocrlf` setting can help)

### Git Commit Messages

Commit messages should adhere to the guidelines in tpope's
[A Note About Git Commit Messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)

In short:

* Use the imperative mood. ("Fix bug", not "Fixed bug" or "Fixes bug")
* Limit the first line to 50 characters or less, followed by a blank line
and detail paragraphs (limit detail lines to about 72 characters).
* Reference issue numbers or pull requests whenever possible.

### JavaScript Styleguide

* Place `module.exports` at or near the top of the file.
* Defined functions are hoisted, so it is appropriate to define the
function after you export it.
* When exporting an object, define it first, then export it, and then add
methods or properties.
* Do not use ES2015 specific features (for example, do not use `let`, `const`,
or `class`).
* All callbacks should follow the standard Node.js callback signature.
* Your JavaScript should properly pass the linter (`make jslint`).

### C++ Styleguide

* Class member variables should be prefixed with `m_`.
* Use a comment when pointer ownership has changed hands.
* Your C++ should properly pass the `cpplint.py` in the `make lint` test.

### Specs Styleguide

* Write all JavaScript tests by using the `mocha` testing framework.
* All `mocha` tests should use exports syntax.
* All `mocha` test files should be suffixed with `.spec.js` instead of `.js`.
* Unit tests should mirror the JavaScript files they test (for example,
`lib/client.js` is tested in `test/client.spec.js`).
* Unit tests should have no outside service dependencies. Any time a dependency,
like Kafka, exists, you should create an end-to-end test.
* You may mock a connection in a unit test if it is reliably similar to its real
variant.

### Documentation Styleguide

* Write all JavaScript documentation in jsdoc-compatible inline comments.
* Each docblock should have references to return types and parameters. If an
object is a parameter, you should also document any required subproperties.
* Use `@see` to reference similar pieces of code.
* Use comments to document your code when its intent may be difficult to understand.
* All documentation outside of the code should be in Github-compatible markdown.
* Make good use of font variations like __bold__ and *italics*.
* Use headers and tables of contents when they make sense.

## Debugging

### Debugging C++

Use `gdb` for debugging (as shown in the following example).

```
node-gyp rebuild --debug
gdb node
(gdb) set args "path/to/file.js"
(gdb) run
[output here]
```

You can add breakpoints and so on after that.
20 changes: 20 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) <year> <copyright holders>

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.
82 changes: 82 additions & 0 deletions Makefile
@@ -0,0 +1,82 @@
NODE-GYP ?= node_modules/.bin/node-gyp
PYTHON ?= python
NODE ?= node
CPPLINT ?= cpplint.py
BUILDTYPE ?= Release
TESTS = "test/**/*.js"
E2E_TESTS = $(wildcard e2e/*.spec.js)
TEST_REPORTER =
TEST_OUTPUT =
CONFIG_OUTPUTS = \
build/bindings.target.mk \
build/Makefile \
build/binding.Makefile build/config.gypi

CPPLINT_FILES = $(wildcard src/*.cc src/*.h)
CPPLINT_FILTER = -legal/copyright
JSLINT_FILES = $(wildcard lib/**/*.js test/**/*.js)

PACKAGE = $(shell node -pe 'require("./package.json").name.split("/")[1]')
VERSION = $(shell node -pe 'require("./package.json").version')

GYPBUILDARGS=
ifeq ($(BUILDTYPE),Debug)
GYPBUILDARGS=--debug
endif

.PHONY: all clean lint test lib docs e2e ghpages

all: lint lib test e2e

lint: cpplint jslint

cpplint:
@$(PYTHON) $(CPPLINT) --filter=$(CPPLINT_FILTER) $(CPPLINT_FILES)

jslint: node_modules/.dirstamp
@./node_modules/.bin/jshint $(JSLINT_FILES)

lib: node_modules/.dirstamp $(CONFIG_OUTPUTS)
@$(NODE-GYP) build $(GYPBUILDARGS)

node_modules/.dirstamp: package.json
@npm update --loglevel warn
@touch $@

$(CONFIG_OUTPUTS): node_modules/.dirstamp binding.gyp
@$(NODE-GYP) configure

test: node_modules/.dirstamp
@./node_modules/.bin/mocha $(TEST_REPORTER) $(TESTS) $(TEST_OUTPUT)

e2e: $(E2E_TESTS)
@$(NODE) e2e/consumer.spec.js && $(NODE) e2e/producer.spec.js && $(NODE) e2e/both.spec.js


define release
NEXT_VERSION=$(shell node -pe 'require("semver").inc("$(VERSION)", "$(1)")')
node -e "\
var j = require('./package.json');\
j.version = \"$$NEXT_VERSION\";\
var s = JSON.stringify(j, null, 2);\
require('fs').writeFileSync('./package.json', s);" && \
git commit -m "release $$NEXT_VERSION" -- package.json && \
git tag "$$NEXT_VERSION" -m "release $$NEXT_VERSION"
endef

docs: node_modules/.dirstamp
@rm -rf docs
@./node_modules/jsdoc/jsdoc.js --destination docs \
--recurse -R ./README.md \
-t "./node_modules/toolkit-jsdoc/" \
--tutorials examples ./lib

gh-pages: node_modules/.dirstamp
@./make_docs.sh

release-patch:
@$(call release,patch)

clean: node_modules/.dirstamp
@rm -f deps/librdkafka/config.h
@$(NODE-GYP) clean

0 comments on commit 0edd0d4

Please sign in to comment.