Commit b98bd902 authored by Tobias Steiner's avatar Tobias Steiner
Browse files

Consume in interval and not a single call

parent ec03d9a6
import {Linker} from './neo4j-linker';
import {Core} from 'geolinker-common';
import Timer = NodeJS.Timer;
/**
* load sourcemap and config
......@@ -30,14 +31,19 @@ kafka.init().then(() => {
/**
* Get next from kafka
*/
let index: Timer;
const next = () => {
consumer.consume(1);
index = setInterval(() => {
// start consuming
consumer.consume(100);
}, 1);
};
/**
* On data, write stuff to neo4j
*/
consumer.on('data', (rawData) => {
clearInterval(index);
core.getReporter().setDataIn(1);
// create new node
// rawData.parsed.provider = 'geonames';
......@@ -49,8 +55,6 @@ kafka.init().then(() => {
core.getLogger().error(JSON.stringify(error));
next();
});
// start consuming
next();
});
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment