Skip to content
This repository was archived by the owner on Oct 19, 2025. It is now read-only.
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
12 changes: 8 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ module.exports = {
"node": true,
"mocha": true
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2017
},
"parser": '@typescript-eslint/parser',
"plugins": [
'@typescript-eslint',
],
"extends": [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
"rules": {
"indent": [
"error",
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ logs
.vscode

certs

# generated files
dist
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ test/
.eslintrc.js
.gitignore
.jshintrc
.travis.yml
.travis.yml
src
.github/
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# sinek CHANGELOG

## 2020-08-10, Version 10.0.0
** **BREAKING removed deprecated client versions
* **BREAKING** removed node-rdkafka
* KafkaJS and primary connection to kafka
* Convert to typescript.

## 2020-04-19, Version 9.1.0

* support for message headers in NProducer
Expand Down
57 changes: 27 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,46 +34,43 @@ npm install --save sinek

## Usage

### Usage - Native Client (based on node-rdkafka)
### Usage - JS Client (based on kafka.js)

#### Please Note:
```javascript
const {
JSConsumer,
JSProducer
} = require("sinek");

You will have to manually install `node-rdkafka` alongside sinek.
(This requires a Node.js version between 9 and 12 and will not work with Node.js >= 13, last tested with 12.16.1)
const jsProducerConfig = {
clientId: "my-app",
brokers: ["kafka1:9092"]
}

On Mac OS High Sierra / Mojave:
`CPPFLAGS=-I/usr/local/opt/openssl/include LDFLAGS=-L/usr/local/opt/openssl/lib yarn add --frozen-lockfile node-rdkafka@2.7.4`
(async () => {

Otherwise:
`yarn add --frozen-lockfile node-rdkafka@2.7.4`
const topic = "my-topic";

(Please also note: Doing this with npm does not work, it will remove your deps, `npm i -g yarn`)
const producer = new JSProducer(jsProducerConfig);
const consumer = new JSConsumer(topic, jsConsumerConfig);

```javascript
const {
NConsumer,
NProducer
} = require("sinek");
```
producer.on("error", error => console.error(error));
consumer.on("error", error => console.error(error));

* [Native Client (NConsumer & NProducer)](docs/native.md)
await consumer.connect();

### Usage - JS Client (based on kafka.js)
// consume from a topic.
consumer.consume(async (messages) => {
messages.forEach((message) => {
console.log(message);
})
});

```javascript
const {
JSConsumer,
JSProducer
} = require("sinek");
```

### Usage - Old JS Client (based on kafka-node)
// Produce messages to a topic.
await producer.connect();
producer.send(topic, "a message")
})().catch(console.error);

```javascript
const {
Consumer,
Producer
} = require("sinek");
```

# Further Docs
Expand Down
Loading