Skip to content

Commit

Permalink
Update to remove old kafka modules (#154)
Browse files Browse the repository at this point in the history
* Removed kafka-node and node-rdkafka to only support kafkaJS. Updated tests to reflect

* Cleaned up old config

* Converted to typescript. Added types where missing.

* Fixed tests, such as ensuring message sending order

* Upgraded wurstmeister/kafka docker to 2.11-1.1.1. Updated stop script to remove volumes to ensure we can run clean. Updated CHANGELOG

* Removed debug code. Removed empty methods and updated Analytics to set client as abstract so the consumer/producer is forced to set the client

* Added typescript eslint

* Fixed error linting errors

* Added missing new line

Co-authored-by: Robert Shepherd <[email protected]>
  • Loading branch information
rob3000 and rob3000 authored Aug 17, 2020
1 parent 16395fe commit b789352
Show file tree
Hide file tree
Showing 43 changed files with 1,377 additions and 6,210 deletions.
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 [email protected]`
(async () => {

Otherwise:
`yarn add --frozen-lockfile [email protected]`
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

0 comments on commit b789352

Please sign in to comment.