diff --git a/CHANGELOG.md b/CHANGELOG.md index 676964a..2104bf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # sinek CHANGELOG +## 2018-05-31, Version 6.16.0 + +* updated NConsumer and NProducer to debug and concat errors of require of native lib + ## 2018-03-27, Version 6.15.1 * node-rdkafka has seg fault bugs in 2.3.1 -> falling back to 2.2.3 diff --git a/lib/librdkafka/NConsumer.js b/lib/librdkafka/NConsumer.js index 1cd0651..c159384 100644 --- a/lib/librdkafka/NConsumer.js +++ b/lib/librdkafka/NConsumer.js @@ -53,14 +53,6 @@ class NConsumer extends EventEmitter { constructor(topics, config = { options: {} }) { super(); - try { - if(!BlizzKafka){ - BlizzKafka = require("node-rdkafka"); - } - } catch(error){ - throw new Error("You have to install node-rdkafka to use NConsumer."); - } - if(!config){ throw new Error("You are missing a config object."); } @@ -69,6 +61,15 @@ class NConsumer extends EventEmitter { config.logger = DEFAULT_LOGGER; } + try { + if(!BlizzKafka){ + BlizzKafka = require("node-rdkafka"); + } + } catch(error){ + config.logger.error(error); + throw new Error("You have to install node-rdkafka to use NConsumer. " + error.message); + } + if(!config.options){ config.options = {}; } diff --git a/lib/librdkafka/NProducer.js b/lib/librdkafka/NProducer.js index 04ca7af..a41dc32 100644 --- a/lib/librdkafka/NProducer.js +++ b/lib/librdkafka/NProducer.js @@ -65,14 +65,6 @@ class NProducer extends EventEmitter { constructor(config, _, defaultPartitionCount = 1) { super(); - try { - if (!BlizzKafka) { - BlizzKafka = require("node-rdkafka"); - } - } catch (error) { - throw new Error("You have to install node-rdkafka to use NProducer."); - } - if (!config) { throw new Error("You are missing a config object."); } @@ -81,6 +73,15 @@ class NProducer extends EventEmitter { config.logger = DEFAULT_LOGGER; } + try { + if (!BlizzKafka) { + BlizzKafka = require("node-rdkafka"); + } + } catch (error) { + config.logger.error(error); + throw new Error("You have to install node-rdkafka to use NProducer. " + error.message); + } + if (!config.options) { config.options = {}; } diff --git a/package.json b/package.json index 9ac3588..c14118f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sinek", - "version": "6.15.2", + "version": "6.16.0", "description": "Node.js kafka client, consumer, producer polite out of the box", "main": "index.js", "scripts": {