Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const pEvent = require('p-event');
const Kafka = require('node-rdkafka');
const defaultOptions = {
producerConfig: {
'metadata.broker.list': ['localhost:9092']
}
};
class KnackHighLevelProducer extends Kafka.HighLevelProducer {
constructor(options = defaultOptions) {
super(options.producerConfig);
this._options = options;
}
get options() {
return this._options;
}
async connect() {
const connectEvent = pEvent(this, 'ready');
super.connect();
const connection = await Promise.resolve(connectEvent);
return connection;
}