Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
log('Using Consumer');
consumer = new kafka.Consumer(
client,
[
{
topic: 'test'
}
],
{
fromOffset: false,
groupId: uuid()
}
);
} else if (process.env.CONSUMER_TYPE === 'highLevel') {
log('Using HighLevelConsumer');
consumer = new kafka.HighLevelConsumer(
client,
[
{
topic: 'test'
}
],
{
fromOffset: false,
groupId: uuid()
}
);
} else {
log('Using ConsumerGroup');
consumer = new kafka.ConsumerGroup(
{
host: process.env.ZOOKEEPER,
function(callback) {
var groupId = self.broadcast ? self.name : channel;
if (channel) {
self.kafkaConsumer = new kafka.HighLevelConsumer(self.connectionClient, [{topic: channel}], {groupId: groupId});
self.kafkaConsumer.on('error', function(err) {
console.log(err);
});
}
callback();
},
function(callback) {
var KafkaClient = function(name, config){
MessagingClient.call(this, name, config);
this.connectionClient = kafka.Client(config.host+':'+config.port+'/', name);
this.kafkaConsumer = new kafka.HighLevelConsumer(this.connectionClient, [{topic: config.topic}], {groupId: config.topic});
this.kafkaConsumer.on('error', function() {});
this.kafkaProducer = new kafka.HighLevelProducer(this.connectionClient);
this.kafkaProducer.on('error', function() {});
};