From 82213ee0b63429273d01715bb34dae2ec07347ae Mon Sep 17 00:00:00 2001 From: Espen Volden Date: Mon, 16 Nov 2015 18:42:01 +0100 Subject: [PATCH 1/2] Log right number of records --- index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 34e9625..0f27d30 100644 --- a/index.js +++ b/index.js @@ -67,10 +67,6 @@ function ElasticsearchBulkIndexWritable(client, options) { * @param {Function} callback */ ElasticsearchBulkIndexWritable.prototype.bulkWrite = function bulkWrite(records, callback) { - if (this.logger) { - this.logger.debug('Writing %d records to Elasticsearch', records.length); - } - this.client.bulk({ body: records }, function bulkCallback(err, data) { if (err) { err.records = records; @@ -95,10 +91,6 @@ ElasticsearchBulkIndexWritable.prototype.bulkWrite = function bulkWrite(records, return callback(error); } - if (this.logger) { - this.logger.info('Wrote %d records to Elasticsearch', records.length); - } - callback(); }.bind(this)); }; @@ -121,11 +113,19 @@ ElasticsearchBulkIndexWritable.prototype._flush = function _flush(callback) { return callback(error); } + if (this.logger) { + this.logger.debug('Writing %d records to Elasticsearch', this.queue.length); + } + this.bulkWrite(records, function(err) { if (err) { return callback(err); } + if (this.logger) { + this.logger.info('Wrote %d records to Elasticsearch', this.queue.length); + } + this.writtenRecords += this.queue.length; this.queue = []; From 72701ab630ee03f8181696c754f4b0f0b8569670 Mon Sep 17 00:00:00 2001 From: Espen Volden Date: Mon, 16 Nov 2015 18:43:01 +0100 Subject: [PATCH 2/2] v0.1.2 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63e301c..bc7f07f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [0.1.2] - 2015-11-16 +### Fixed +- Log right amount of records. The records count that was logged was + doubled in previous release. + ## [0.1.1] - 2015-11-16 ### Fixed - Do not write if there are no records in the queue when the stream gets closed diff --git a/package.json b/package.json index 860149a..26e3ac1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "elasticsearch-bulk-index-stream", - "version": "0.1.1", + "version": "0.1.2", "description": "A writable stream for bulk indexing records in Elasticsearch", "main": "index.js", "scripts": {