Commit cae6dc2db5c8dfdf88ab28c33b62e025f56a6209

Authored by Adhidarma Hadiwinoto
1 parent 99bf9e4c4c
Exists in master

RESEND-DELAY: configuration

Showing 1 changed file with 5 additions and 5 deletions Side-by-side Diff

gateway/resend-delay.js
... ... @@ -7,8 +7,8 @@ const config = require('./config');
7 7 const logger = require('./logger');
8 8  
9 9 const resendHandlers = LRU({
10   - max: Number(config.auto_resend_delay_max_handler) || 5000,
11   - maxAge: 1000 * 3600 * 36
  10 + max: (( config && config.auto_resend && config.auto_resend.max_handler ) ? Number(config.auto_resend.max_handler) : 0) || 5000,
  11 + maxAge: 1000 * 3600 * 24
12 12 });
13 13  
14 14 function _resend(task, request) {
... ... @@ -22,8 +22,8 @@ function _resend(task, request) {
22 22 request(task);
23 23 }
24 24  
25   -function cancel(task) {
26   - const trx_id = ( typeof task === 'string' ) ? task : task.trx_id;
  25 +function cancel(_task) {
  26 + const trx_id = ( typeof _task === 'string' ) ? _task : _task.trx_id;
27 27 if (!trx_id) { return; }
28 28  
29 29 const oldHandler = resendHandlers.get(trx_id);
... ... @@ -62,7 +62,7 @@ function register(task, request) {
62 62 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});
63 63 const handlerData = {
64 64 handler: setTimeout(
65   - function() { resend(task, request); }
  65 + function() { _resend(task, request); },
66 66 config.auto_resend.delay_ms
67 67 ),
68 68 task: task,