Compare View

switch
from
...
to
 
Commits (5)

Changes

Showing 3 changed files Side-by-side Diff

gateway/resend-delay.js
... ... @@ -18,23 +18,29 @@ function isEnabled() {
18 18 function _resend(task, request) {
19 19 const trx_date = moment(task.created).format('YYYYMMDD');
20 20 if (trx_date !== moment().format('YYYYMMDD')) {
21   - logger.info('RESEND-DELAY: skip resend because of different trx date', {trx_id: task.trx_id, destination: task.destination, product: task.product, remote_product: task.remote_product, created: task.created});
  21 + logger.info('SDK-RESEND-DELAY: skip resend because of different trx date', {trx_id: task.trx_id, destination: task.destination, product: task.product, remote_product: task.remote_product, created: task.created});
22 22 return;
23 23 }
24 24  
25   - logger.verbose('RESEND-DELAY: Resending trx', {trx_id: task.trx_id, destination: task.destination, product: task.product, remote_product: task.remote_product, created: task.created});
  25 + logger.verbose('SDK-RESEND-DELAY: Resending trx', {trx_id: task.trx_id, destination: task.destination, product: task.product, remote_product: task.remote_product, created: task.created});
26 26 request(task);
27 27 }
28 28  
29 29 function cancel(_task) {
30 30 const trx_id = ( typeof _task === 'string' ) ? _task : _task.trx_id;
31   - if (!trx_id) { return; }
  31 + if (!trx_id) {
  32 + logger.warn('SDK-RESEND-DELAY: Skipping cancel because of undefined trx_id');
  33 + return;
  34 + }
32 35  
33 36 const oldHandler = resendHandlers.get(trx_id);
34   - if (!oldHandler) { return; }
  37 + if (!oldHandler) {
  38 + config.debug_sdk_resend_delay && logger.verbose('SDK-RESEND-DELAY: Skipping cancel because of undefined oldHandler', {trx_id: trx_id});
  39 + return;
  40 + }
35 41  
36 42 const task = oldHandler.task;
37   - logger.verbose('RESEND-DELAY: Canceling task', {trx_id: task.trx_id, destination: task.destination, product: task.product, remote_product: task.remote_product});
  43 + logger.verbose('SDK-RESEND-DELAY: Canceling task', {trx_id: task.trx_id, destination: task.destination, product: task.product, remote_product: task.remote_product});
38 44  
39 45 if (oldHandler.handler) { clearTimeout(oldHandler.handler); }
40 46 resendHandlers.del(trx_id);
... ... @@ -42,7 +48,7 @@ function cancel(_task) {
42 48  
43 49 function register(task, request) {
44 50 if (!task.trx_id) {
45   - logger.warn('RESEND-DELAY: Invalid task on register')
  51 + logger.warn('SDK-RESEND-DELAY: Invalid task on register')
46 52 return;
47 53 }
48 54  
... ... @@ -58,12 +64,12 @@ function register(task, request) {
58 64 }
59 65  
60 66 if (retry <= 0) {
61   - logger.verbose('RESEND-DELAY: Retry exceeded', {trx_id: task.trx_id, destination: task.destination, product: task.product, remote_product: task.remote_product});
  67 + logger.verbose('SDK-RESEND-DELAY: Retry exceeded', {trx_id: task.trx_id, destination: task.destination, product: task.product, remote_product: task.remote_product});
62 68 cancel(task);
63 69 return;
64 70 }
65 71  
66   - logger.verbose('RESEND-DELAY: Registering task request', {trx_id: task.trx_id, destination: task.destination, product: task.product, remote_product: task.remote_product, delay_ms: config.auto_resend.delay_ms, retry: retry});
  72 + logger.verbose('SDK-RESEND-DELAY: Registering task request', {trx_id: task.trx_id, destination: task.destination, product: task.product, remote_product: task.remote_product, delay_ms: config.auto_resend.delay_ms, retry: retry});
67 73 const handlerData = {
68 74 handler: setTimeout(
69 75 function() { _resend(task, request); },
... ... @@ -79,7 +85,7 @@ function register(task, request) {
79 85 setInterval(
80 86 function() {
81 87 resendHandlers.prune();
82   - logger.verbose('RESEND-DELAY: pruned');
  88 + logger.verbose('SDK-RESEND-DELAY: pruned');
83 89 },
84 90 24 * 3600 * 1000
85 91 )
1 1 {
2 2 "name": "komodo-sdk",
3   - "version": "1.26.3",
  3 + "version": "1.26.4",
4 4 "description": "SDK for Komodo",
5 5 "main": "index.js",
6 6 "scripts": {
... ... @@ -24,6 +24,14 @@ function run(msg, rules) {
24 24 for(let i = 0; i < rules_count; i++) {
25 25 const rule = rules[i];
26 26  
  27 + if (typeof rule.pattern !== 'string') {
  28 + continue;
  29 + }
  30 +
  31 + if (typeof rule.rc !== 'string' && typeof rule.result !== 'string') {
  32 + continue;
  33 + }
  34 +
27 35 logOnDebug('RC-FROM-MSG: checking with rule: ' + JSON.stringify(rule));
28 36 const re = (typeof rule.flags === 'string') ? new RegExp(rule.pattern, rule.flags) : new RegExp(rule.pattern);
29 37 if (msg.search(re) > 0) {