-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
827 additions
and
860 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 |
---|---|---|
@@ -1,18 +1,7 @@ | ||
"use strict"; | ||
|
||
export { KStream } from "./lib/dsl/KStream"; | ||
export { KTable } from "./lib/dsl/KTable"; | ||
export { KStream, KTable } from "./lib/dsl"; | ||
export { KafkaFactory } from "./lib/KafkaFactory"; | ||
export { KafkaStreams } from "./lib/KafkaStreams"; | ||
export { KStorage } from "./lib/KStorage.js"; | ||
export { KStorage } from "./lib/KStorage"; | ||
export { KafkaClient } from "./lib/client/KafkaClient"; | ||
|
||
// module.exports = { | ||
// default: KafkaStreams, | ||
// KStream, | ||
// KTable, | ||
// KafkaFactory, | ||
// KafkaStreams, | ||
// KStorage, | ||
// KafkaClient | ||
// }; |
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
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 |
---|---|---|
|
@@ -157,5 +157,3 @@ export class KafkaStreams extends EventEmitter { | |
}); | ||
} | ||
} | ||
|
||
export default KafkaStreams; |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import Promise from "bluebird"; | ||
import { Promise } from "bluebird"; | ||
|
||
/** | ||
* used to count keys in a stream | ||
|
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import Promise from "bluebird"; | ||
import { Promise } from "bluebird"; | ||
|
||
/** | ||
* used grab the lowest value of | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import Promise from "bluebird"; | ||
import { Promise } from "bluebird"; | ||
|
||
/** | ||
* used to sum up key values in a stream | ||
|
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
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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import { KafkaStreams } from "../../src/index"; | ||
import { nativeConfig as config } from "../test-config"; | ||
|
||
const keyValueMapperEtl = (message) => { | ||
console.log(message); | ||
const elements = message.toLowerCase().split(" "); | ||
return { | ||
key: elements[0], | ||
value: elements[1] | ||
}; | ||
}; | ||
|
||
/* | ||
E2E or integration tests using a kafka broker are always | ||
a bit flakey, with the right configuration and enough patience (mocha timeouts) | ||
it is relatively possible. | ||
*/ | ||
|
||
describe("E2E INT", () => { | ||
|
||
let kafkaStreams = null; | ||
|
||
const topic = "my-input-topic"; | ||
const outputTopic = "my-output-topic"; | ||
|
||
const messages = [ | ||
"bla", | ||
"blup", | ||
"bluuu", | ||
"bla", | ||
"bla", | ||
"blup", | ||
"xd", | ||
"12x3" | ||
]; | ||
|
||
before(() => { | ||
kafkaStreams = new KafkaStreams(config); | ||
}); | ||
|
||
after(async () => { | ||
await kafkaStreams.closeAll(); | ||
}); | ||
|
||
it("should be able to produce to a topic via stream", done => { | ||
|
||
const stream = kafkaStreams.getKStream(); | ||
stream.to(topic); | ||
|
||
let count = 0; | ||
stream.createAndSetProduceHandler().on("delivered", message => { | ||
console.log(message.value); | ||
count++; | ||
if (count === messages.length) { | ||
setTimeout(done, 250); | ||
} | ||
}); | ||
|
||
stream.start().then(() => { | ||
console.log("started"); | ||
stream.writeToStream(messages); | ||
}).catch((error) => { | ||
done(error); | ||
}); | ||
}); | ||
|
||
it("should give kafka some time", done => { | ||
setTimeout(done, 2500); | ||
}); | ||
|
||
it("should run complexer wordcount sample", done => { | ||
|
||
const stream = kafkaStreams.getKStream(); | ||
|
||
stream | ||
.from(topic) | ||
.mapJSONConvenience() //buffer -> json | ||
.mapWrapKafkaValue() //message.value -> value | ||
.map(keyValueMapperEtl) | ||
.countByKey("key", "count") | ||
.filter(kv => kv.count >= 2) | ||
.map(kv => kv.key + " " + kv.count) | ||
.tap(_ => { }) | ||
.wrapAsKafkaValue() | ||
.to(outputTopic); | ||
|
||
let count = 0; | ||
stream.createAndSetProduceHandler().on("delivered", () => { | ||
count++; | ||
if (count === 2) { | ||
setTimeout(done, 250); | ||
} | ||
}); | ||
|
||
stream.start(); | ||
}); | ||
|
||
it("should give kafka some time again", done => { | ||
setTimeout(done, 2500); | ||
}); | ||
|
||
it("should be able to consume produced wordcount results", done => { | ||
|
||
const stream = kafkaStreams.getKStream(); | ||
|
||
let count = 0; | ||
stream | ||
.from(outputTopic) | ||
.mapJSONConvenience() //buffer -> json | ||
.tap(_ => { | ||
count++; | ||
if (count === 2) { | ||
setTimeout(done, 100); | ||
} | ||
}) | ||
.forEach(console.log); | ||
|
||
stream.start(); | ||
}); | ||
}); |
Oops, something went wrong.