From df89d6aa56b8d30de44963bc4d5b4f0c7946d5d7 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Sun, 25 Sep 2016 20:49:51 -0700 Subject: [PATCH 01/13] chore(package): update lodash to version 4.16.2 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 82c52ff..d96a27b 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "isprod": "^1.1.0", "json3": "^3.3.2", "jsonpath": "^0.2.6", - "lodash": "4.16.0", + "lodash": "4.16.2", "lokijs": "^1.4.1", "node-uuid": "^1.4.7", "rabbit.js": "0.4.4", From b65a57259c337a8d867f0ab207ce8b41893e0d80 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Tue, 27 Sep 2016 10:16:58 -0700 Subject: [PATCH 02/13] chore(package): update babel-eslint to version 7.0.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d96a27b..d20cb6e 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "devDependencies": { "babel-cli": "^6.5.1", "babel-core": "^6.5.2", - "babel-eslint": "^6.0.0", + "babel-eslint": "^7.0.0", "babel-plugin-transform-function-bind": "^6.5.2", "babel-preset-es2015": "^6.13.2", "chai": "^3.5.0", From e44a9e7f8848d5d7f9cec16cd42157e45bdd6632 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Mon, 3 Oct 2016 10:29:07 -0700 Subject: [PATCH 03/13] chore(package): update lodash to version 4.16.3 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d96a27b..ac2f476 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "isprod": "^1.1.0", "json3": "^3.3.2", "jsonpath": "^0.2.6", - "lodash": "4.16.2", + "lodash": "4.16.3", "lokijs": "^1.4.1", "node-uuid": "^1.4.7", "rabbit.js": "0.4.4", From f349149f8040b722642e8190d294402cc836a3ae Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Mon, 3 Oct 2016 15:50:10 -0700 Subject: [PATCH 04/13] chore(package): update babel-preset-es2015 to version 6.16.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ac2f476..edb8b17 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "babel-core": "^6.5.2", "babel-eslint": "^6.0.0", "babel-plugin-transform-function-bind": "^6.5.2", - "babel-preset-es2015": "^6.13.2", + "babel-preset-es2015": "^6.16.0", "chai": "^3.5.0", "coveralls": "^2.11.13", "dirty-chai": "^1.2.2", From f225355f101c8074c739b0e755d5362a007f94e3 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Mon, 3 Oct 2016 15:50:26 -0700 Subject: [PATCH 05/13] chore(package): update babel-core to version 6.17.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bb2ae91..f966b9c 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ }, "devDependencies": { "babel-cli": "^6.5.1", - "babel-core": "^6.5.2", + "babel-core": "^6.17.0", "babel-eslint": "^7.0.0", "babel-plugin-transform-function-bind": "^6.5.2", "babel-preset-es2015": "^6.13.2", From fe2baa8a4b5935e22b7f23d921842082507a419e Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Thu, 6 Oct 2016 08:56:22 -0700 Subject: [PATCH 06/13] chore(package): update lodash to version 4.16.4 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 17e005e..086a7e2 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "isprod": "^1.1.0", "json3": "^3.3.2", "jsonpath": "^0.2.6", - "lodash": "4.16.3", + "lodash": "4.16.4", "lokijs": "^1.4.1", "node-uuid": "^1.4.7", "rabbit.js": "0.4.4", From 626e992d2601ddcf47b40dfb465c4601f334bf7d Mon Sep 17 00:00:00 2001 From: Rafael Roman Date: Thu, 13 Oct 2016 20:28:46 +0200 Subject: [PATCH 07/13] adding test script --- setup-test.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 setup-test.sh diff --git a/setup-test.sh b/setup-test.sh new file mode 100755 index 0000000..7fad824 --- /dev/null +++ b/setup-test.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +docker run -d -p 9200:9200 -p 9300:9300 --name es4test elasticsearch:2 +docker run -d -p 5671:5671 -p 5672:5672 -p 25672:25672 --name mq4test rabbitmq:3 From f324e2cbbef586591250d419c95fca9d75a44264 Mon Sep 17 00:00:00 2001 From: Rafael Roman Date: Thu, 13 Oct 2016 20:29:06 +0200 Subject: [PATCH 08/13] adding resend property to Module --- src/module.js | 8 ++++++-- test/module.spec.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/module.js b/src/module.js index b1f4f7c..6a666aa 100644 --- a/src/module.js +++ b/src/module.js @@ -29,6 +29,7 @@ class Module extends EventEmitter { * a Peristence module is the module that only persists data, you can only have a single persistence module (same instances can be launched by service to process heavy load) * @param {String} [options.positivePath] the json path {@see https://github.com/dchester/jsonpath} that when matched messages will be sent to this module * @param {String} [options.negativePath] the json path {@see https://github.com/dchester/jsonpath} that when NOT matched messages will be sent to this module + * @param {boolean} [options.resend] when false the orchestrator will never send the message to the module more than once * */ @@ -41,7 +42,8 @@ class Module extends EventEmitter { registerQueue: 'o_register', amqpURL: 'amqp://localhost:5672', type: 'processor', - prefetch: 1 + prefetch: 1, + resend: true }; if (typeof options === 'string') { @@ -66,6 +68,7 @@ class Module extends EventEmitter { this.workerQueueName = null; this.prefetch = options.prefetch; this.type = options.type; + this.resend = options.resend; // --------------------------------------------- @@ -94,7 +97,8 @@ class Module extends EventEmitter { workerQueueName: this.workerQueueName, messagesQueue: this.messagesQueue, prefetch: this.prefetch, - type: this.type + type: this.type, + resend: this.resend }); } diff --git a/test/module.spec.js b/test/module.spec.js index d866345..83b466a 100644 --- a/test/module.spec.js +++ b/test/module.spec.js @@ -31,7 +31,7 @@ describe('Module', function () { // if a new property is added that should be serialized is not added to the toJSON method // it will not be serialized and the functionality might fail. // After verification this constant should be increased by the number of new properties - const expectedKeysSize = 19; + const expectedKeysSize = 20; chai.expect(Object.keys(m).length).to.be.equals(expectedKeysSize); From f89f17e79407166f8f93271de371041abb9e9f9d Mon Sep 17 00:00:00 2001 From: Rafael Roman Date: Thu, 13 Oct 2016 20:29:30 +0200 Subject: [PATCH 09/13] respecting resend property --- src/orchestrator.js | 9 +++++++-- test/orchestrator.spec.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/orchestrator.js b/src/orchestrator.js index 13c332b..6188556 100644 --- a/src/orchestrator.js +++ b/src/orchestrator.js @@ -387,7 +387,7 @@ class Orchestrator { return Promise.resolve().then(() => { module = Orchestrator.checkModule(module); - logger.info('Registering new module', module); + logger.info('Registering new module', module.toJSON()); if (this.isRegistered(module)) { logger.info(`Module ${module.name} already registered for uuid ${module.uuid}`); @@ -413,15 +413,20 @@ class Orchestrator { * Find modules that matches for the give message * ordered by their registration _order * @param {Object} message + * @param {Object} meta the message metadata * @return {Promise} */ - findMatchingModules(message) { + findMatchingModules(message, meta) { return new Promise((resolve) => { logger.debug('Finding modules that matches', message); const modules = this.modulesCollection.where((module) => { if (module.type === 'persistence') { return false; } + if (meta && meta.service === module.service && !module.resend) { + return false; + } + let matchesPositive = true; let matchesNegative = true; diff --git a/test/orchestrator.spec.js b/test/orchestrator.spec.js index 2772510..7e38491 100644 --- a/test/orchestrator.spec.js +++ b/test/orchestrator.spec.js @@ -198,6 +198,43 @@ describe('Orchestrator', function () { }); }); + + it('Should resend to the same service when module.resend is omitted', function () { + // const o = new Orchestrator(); + + return o.listen().then(() => { + const originalModule = new Module({ service: serviceName }); + + originalModule.negativePath = '$.negativeKeyName'; + + return o.register(originalModule).then(() => { + return o.findMatchingModules({ key: 'value' }, { service: serviceName }); + }).then((modules) => { + chai.expect(modules).to.be.a('array'); + chai.expect(modules).not.to.be.empty(); + chai.expect(modules[0]).to.have.property('uuid').that.is.equals(originalModule.uuid); + }); + }); + }); + + + it('Should not resend to the same service when module.resend is false', function () { + // const o = new Orchestrator(); + + return o.listen().then(() => { + const originalModule = new Module({ service: serviceName, resend: false }); + + originalModule.negativePath = '$.negativeKeyName'; + + return o.register(originalModule).then(() => { + return o.findMatchingModules({ key: 'value' }, { service: serviceName }); + }).then((modules) => { + chai.expect(modules).to.be.a('array'); + chai.expect(modules).to.be.empty(); + }); + }); + }); + it('Should listen with default options', function () { // const o = new Orchestrator(); From 5d19238e804432dd3c0a2bc1f11fc6091267de2e Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Tue, 25 Oct 2016 02:05:43 +0200 Subject: [PATCH 10/13] chore(package): update babel-core to version 6.18.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 086a7e2..7b3744a 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ }, "devDependencies": { "babel-cli": "^6.5.1", - "babel-core": "^6.17.0", + "babel-core": "^6.18.0", "babel-eslint": "^7.0.0", "babel-plugin-transform-function-bind": "^6.5.2", "babel-preset-es2015": "^6.16.0", From c7a5f6259a44c20477dd139ab16392c5657ea11d Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Tue, 25 Oct 2016 03:46:19 +0200 Subject: [PATCH 11/13] chore(package): update babel-preset-es2015 to version 6.18.0 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 086a7e2..cdcc095 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "babel-core": "^6.17.0", "babel-eslint": "^7.0.0", "babel-plugin-transform-function-bind": "^6.5.2", - "babel-preset-es2015": "^6.16.0", + "babel-preset-es2015": "^6.18.0", "chai": "^3.5.0", "coveralls": "^2.11.13", "dirty-chai": "^1.2.2", From d38d7150a0c1ae2bf697df486adcbb5e2a6a8b6b Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Thu, 27 Oct 2016 04:55:34 +0200 Subject: [PATCH 12/13] chore(package): update elasticsearch to version 12.0.1 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 086a7e2..8c4b218 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "body-parser": "^1.15.2", "chalk": "^1.1.1", "docker-names": "^1.0.0", - "elasticsearch": "^11.0.1", + "elasticsearch": "^12.0.1", "isprod": "^1.1.0", "json3": "^3.3.2", "jsonpath": "^0.2.6", From 8b5f247259d171d2f366cb764bed0be59be7c4b9 Mon Sep 17 00:00:00 2001 From: Rafael Roman Date: Fri, 28 Oct 2016 18:47:12 +0200 Subject: [PATCH 13/13] upgrade babel-cli --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 26cd477..07b107e 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "winston": "^2.2.0" }, "devDependencies": { - "babel-cli": "^6.5.1", + "babel-cli": "^6.18.0", "babel-core": "^6.18.0", "babel-eslint": "^7.0.0", "babel-plugin-transform-function-bind": "^6.5.2",