-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to remove old kafka modules (#154)
* 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
Showing
43 changed files
with
1,377 additions
and
6,210 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
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 |
---|---|---|
|
@@ -40,3 +40,6 @@ logs | |
.vscode | ||
|
||
certs | ||
|
||
# generated files | ||
dist |
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 |
---|---|---|
|
@@ -10,4 +10,6 @@ test/ | |
.eslintrc.js | ||
.gitignore | ||
.jshintrc | ||
.travis.yml | ||
.travis.yml | ||
src | ||
.github/ |
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
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 |
---|---|---|
|
@@ -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 | ||
|
Oops, something went wrong.