Commit e7f5d2a50dc9c561a293c20181937338346e968b

Authored by Adhidarma Hadiwinoto
1 parent b403448adb
Exists in master and in 1 other branch dev

active sending

Showing 2 changed files with 14 additions and 0 deletions Side-by-side Diff

lib/core-callback/sender.js
... ... @@ -101,6 +101,12 @@ const sender = async (data, xid, retry) => {
101 101 });
102 102  
103 103 matrix.callback_sender.sent += 1;
  104 + matrix.callback_sender.active_count += 1;
  105 + matrix.callback_sender.active_sending[xid] = {
  106 + ts: new Date(),
  107 + trxId: data.trx_id,
  108 + reverseUrl: data.reverse_url,
  109 + };
104 110  
105 111 if (isPostpaid) {
106 112 matrix.callback_sender.sent_using_post += 1;
... ... @@ -121,6 +127,7 @@ const sender = async (data, xid, retry) => {
121 127 ts: new Date(),
122 128 eCode: e.code,
123 129 eMessage: e.message,
  130 + trxId: data.trx_id,
124 131 reverseUrl: data.reverse_url,
125 132 httpStatus: e.response && e.response.status,
126 133 responseBody: e.response && e.response.data,
... ... @@ -145,6 +152,11 @@ const sender = async (data, xid, retry) => {
145 152 });
146 153 sender(data, xid, (retry || 0) + 1);
147 154 }
  155 + } finally {
  156 + matrix.callback_sender.active_count -= 1;
  157 + if (matrix.callback_sender.active_sending[xid]) {
  158 + delete matrix.callback_sender.active_sending[xid];
  159 + }
148 160 }
149 161 };
150 162  
... ... @@ -24,5 +24,7 @@ module.exports = {
24 24 sent_using_get: 0,
25 25 sent_using_post: 0,
26 26 last_error: null,
  27 + active_count: 0,
  28 + active_sending: {},
27 29 },
28 30 };