node-kafka-streams
// suggested Node.js version: v12.16.1
npm install --save kafka-streams
const {KafkaStreams} = require("kafka-streams");
const config = require("./config.json");
const factory = new KafkaStreams(config);
const kstream = factory.getKStream("input-topic");
const ktable = factory.getKTable(/* .. */);
kstream.merge(ktable).filter(/* .. */).map(/* .. */).reduce(/* .. */).to("output-topic");
CHANGES: The latest version brings a lot of changes, please check here before updating.
API Overview
- Quick Start
- Message 'to' and 'from' Apache Kafka
- API Info
- Documentation
- Operator descriptions
- Examples
- Native Client | SSL, SASL, Kerberos
You might also like
README Overview
- Prerequisites
- Aim of this Library
- Description
- Port Progress Overview
- Operator Implementations
- Additional Operators
- Stream Action Implementations
- Join Operators Status
- Window Operations
- FAQ - More
Prerequisites
- Kafka broker should be version
>= 0.11.x
- Node.js should be version
>= 8.x.x
A note on native mode
If you are using the native mode (config: { noptions: {} }
).
You will have to manually install node-rdkafka
alongside kafka-streams.
(This requires a Node.js version between 9 and 12 and will not work with Node.js >= 13, last tested with 12.16.1)
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
Otherwise:
yarn add --frozen-lockfile node-rdkafka@2.7.4
(Please also note: Doing this with npm does not work, it will remove your deps, npm i -g yarn
)
Aim of this Library
- this is not a 1:1 port of the official JAVA kafka-streams
- the goal of this project is to give at least the same options to a nodejs developer that kafka-streams provides for JVM developers
- stream-state processing, table representation, joins, aggregate etc. I am aiming for the easiest api access possible checkout the word count example
Description
kafka-streams :octopus: equivalent for nodejs :sparkles::turtle::rocket::sparkles: build on super fast :fire: observables using most.js :metal:
ships with sinek :pray: for backpressure
comes with js and native Kafka client, for more performance and SSL, SASL and Kerberos features
the lib also comes with a few window
operations that are more similar to Apache Flink,
yet they still feel natural in this api :squirrel:
overwriteable local-storage solution allows for any kind of datastore e.g. RocksDB, Redis, Postgres..
async (Promises) and sync stream operators e.g. stream$.map()
or stream$.asyncMap()
super easy API :goberserk:
the lib is based on sinek
, which is based on kafka-node's ConsumerGroups
Port Progress Overview
- <input checked="" disabled="" type="checkbox"> core structure
- <input checked="" disabled="" type="checkbox"> KStream base - stream as a changelog
- <input checked="" disabled="" type="checkbox"> KTable base - stream as a database
- <input checked="" disabled="" type="checkbox"> KStream & KTable cloning
- <input checked="" disabled="" type="checkbox"> complex stream join structure
- <input disabled="" type="checkbox"> advanced joins see
- <input disabled="" type="checkbox"> windows (for joins) see
- <input disabled="" type="checkbox"> flink like window operations
- <input checked="" disabled="" type="checkbox"> word-count example
- <input checked="" disabled="" type="checkbox"> more examples
- <input checked="" disabled="" type="checkbox"> local-storage for etl actions
- <input checked="" disabled="" type="checkbox"> local-storage factory (one per action)
- <input disabled="" type="checkbox"> KStorage example for any DB that supports atomic actions
- <input disabled="" type="checkbox"> backing-up local-storage via kafka
- <input checked="" disabled="" type="checkbox"> kafka client implementation
- <input checked="" disabled="" type="checkbox"> KTable replay to Kafka (produce)
- <input checked="" disabled="" type="checkbox"> stream for topic message production only
- <input checked="" disabled="" type="checkbox"> sinek implementation
- <input checked="" disabled="" type="checkbox"> backpressure mode for KafkaClient
- <input checked="" disabled="" type="checkbox"> auto-json payloads (read-map/write-map)
- <input checked="" disabled="" type="checkbox"> auto producer partition and keyed-message handling
- <input checked="" disabled="" type="checkbox"> documentation
- <input checked="" disabled="" type="checkbox"> API description
- <input disabled="" type="checkbox"> higher join & combine examples
- <input checked="" disabled="" type="checkbox"> embed native client
librdkafka
for more performance - <input checked="" disabled="" type="checkbox"> SSL
- <input checked="" disabled="" type="checkbox"> SASL
- <input checked="" disabled="" type="checkbox"> Kerberos
Operator Implementations
- <input checked="" disabled="" type="checkbox"> map
- <input checked="" disabled="" type="checkbox"> asyncMap
- <input checked="" disabled="" type="checkbox"> constant
- <input checked="" disabled="" type="checkbox"> scan
- <input checked="" disabled="" type="checkbox"> timestamp
- <input checked="" disabled="" type="checkbox"> tap
- <input checked="" disabled="" type="checkbox"> filter
- <input checked="" disabled="" type="checkbox"> skipRepeats
- <input checked="" disabled="" type="checkbox"> skipRepeatsWith
- <input checked="" disabled="" type="checkbox"> slice
- <input checked="" disabled="" type="checkbox"> take
- <input checked="" disabled="" type="checkbox"> skip
- <input checked="" disabled="" type="checkbox"> takeWhile
- <input checked="" disabled="" type="checkbox"> skipWhile
- <input checked="" disabled="" type="checkbox"> until
- <input checked="" disabled="" type="checkbox"> since
- <input checked="" disabled="" type="checkbox"> reduce
- <input checked="" disabled="" type="checkbox"> chainReduce
- <input checked="" disabled="" type="checkbox"> forEach (observe)
- <input checked="" disabled="" type="checkbox"> chainForEach
- <input checked="" disabled="" type="checkbox"> drain
- <input checked="" disabled="" type="checkbox"> _zip
- <input checked="" disabled="" type="checkbox"> _merge
- <input checked="" disabled="" type="checkbox"> _join
- <input checked="" disabled="" type="checkbox"> _combine
- <input checked="" disabled="" type="checkbox"> _sample
- <input checked="" disabled="" type="checkbox"> throttle
- <input checked="" disabled="" type="checkbox"> debounce
- <input checked="" disabled="" type="checkbox"> delay
- <input checked="" disabled="" type="checkbox"> multicast
- A description of the operators can be found here
- Missing an operator? Feel free to open an issue :cop:
Additional Operators
- <input checked="" disabled="" type="checkbox"> mapStringToArray
- <input checked="" disabled="" type="checkbox"> mapArrayToKV
- <input checked="" disabled="" type="checkbox"> mapStringToKV
- <input checked="" disabled="" type="checkbox"> mapParse
- <input checked="" disabled="" type="checkbox"> mapStringify
- <input checked="" disabled="" type="checkbox"> atThroughput
- <input checked="" disabled="" type="checkbox"> mapWrapKafkaPayload
- <input checked="" disabled="" type="checkbox"> mapToFormat
- <input checked="" disabled="" type="checkbox"> mapFromFormat
- Want more? Feel free to open an issue :cop:
Stream Action Implementations
- <input checked="" disabled="" type="checkbox"> countByKey
- <input checked="" disabled="" type="checkbox"> sumByKey
- <input checked="" disabled="" type="checkbox"> min
- <input checked="" disabled="" type="checkbox"> max
- Want more? Feel free to open an issue :cop:
Join Operations
KStream Status
- <input checked="" disabled="" type="checkbox"> merge
- <input disabled="" type="checkbox"> outerJoin
- <input checked="" disabled="" type="checkbox"> innerJoin
- <input disabled="" type="checkbox"> leftJoin
- <input checked="" disabled="" type="checkbox"> branch
KTable Status
- <input checked="" disabled="" type="checkbox"> merge
- <input disabled="" type="checkbox"> outerJoin
- <input disabled="" type="checkbox"> innerJoin
- <input disabled="" type="checkbox"> leftJoin
KTable <-> KStream Status
- <input checked="" disabled="" type="checkbox"> merge
- <input disabled="" type="checkbox"> outerJoin
- <input disabled="" type="checkbox"> innerJoin
- <input disabled="" type="checkbox"> leftJoin
Window Operations
KStream
- <input checked="" disabled="" type="checkbox"> window
- <input disabled="" type="checkbox"> advanced window
- <input disabled="" type="checkbox"> rolling window
More
Can I use this library yet?
Yes.
Are we ready for production yet?
Probably, yes. :smile:
Even More
Forks or Stars give motivation :bowtie: