Compare View

switch
from
...
to
 
Commits (2)

Changes

Showing 4 changed files Side-by-side Diff

... ... @@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
4 4  
5 5 Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6 6  
  7 +#### [v1.44.1](https://gitlab.kodesumber.com/komodo/komodo-sdk/compare/v1.44.0...v1.44.1)
  8 +
  9 +- Add xid on pull [`fb3e2cb`](https://gitlab.kodesumber.com/komodo/komodo-sdk/commit/fb3e2cb62358d4238753eaf4c415e48b8c378c9c)
  10 +
7 11 #### [v1.44.0](https://gitlab.kodesumber.com/komodo/komodo-sdk/compare/v1.43.10...v1.44.0)
8 12  
  13 +> 13 January 2022
  14 +
9 15 - ESLINT on pull [`edf522c`](https://gitlab.kodesumber.com/komodo/komodo-sdk/commit/edf522c31e76c81bdce9f0e9ba22dce45d0b1065)
10 16 - Add global.KOMODO_SDK_DISABLE_PULL [`057c662`](https://gitlab.kodesumber.com/komodo/komodo-sdk/commit/057c6624635feb9754506057061c8eac7e464e31)
11 17 - Change default pull request timeout to 20 secs [`e24aa85`](https://gitlab.kodesumber.com/komodo/komodo-sdk/commit/e24aa85b3a0dd1e6eb9a3452c1d0fd9d7775b244)
... ... @@ -8,6 +8,7 @@ const request = require('request');
8 8 const stringify = require('json-stringify-pretty-compact');
9 9 const logger = require('tektrans-logger');
10 10 const urljoin = require('url-join');
  11 +const uniqid = require('uniqid');
11 12  
12 13 const config = require('../config');
13 14 const matrix = require('../matrix');
... ... @@ -226,22 +227,27 @@ function resendReport(data) {
226 227 );
227 228 }
228 229  
229   -function forwardCoreTaskToPartner(coreMessage, startTime) {
  230 +function forwardCoreTaskToPartner(coreMessage, startTime, xid) {
230 231 let task;
231 232  
232 233 try {
233 234 task = JSON.parse(coreMessage);
234 235 } catch (e) {
235   - logger.warn(`${MODULE_NAME} E757F11A: Exception on parsing CORE pull task response`, { coreMessage, eCode: e.code, eMessage: e.message });
  236 + logger.warn(`${MODULE_NAME} E757F11A: Exception on parsing CORE pull task response`, {
  237 + xid, coreMessage, eCode: e.code, eMessage: e.message,
  238 + });
236 239 return;
237 240 }
238 241  
239 242 if (config.sdk_pull_only_postpaid) {
240   - logger.warn(`${MODULE_NAME} E6662C4F: Got task on sdk_pull_only_postpaid. It should not be happens`, { task });
  243 + logger.warn(`${MODULE_NAME} E6662C4F: Got task on sdk_pull_only_postpaid. It should not be happens`, { xid, task });
241 244 report({
242 245 trx_id: task.trx_id,
243 246 rc: '40',
244   - message: 'GATEWAY ini diset hanya untuk transaksi postpaid (config.sdk_pull_only_postpaid)',
  247 + message: {
  248 + xid,
  249 + msg: 'GATEWAY ini diset hanya untuk transaksi postpaid (config.sdk_pull_only_postpaid)',
  250 + },
245 251 });
246 252 return;
247 253 }
... ... @@ -260,6 +266,7 @@ function forwardCoreTaskToPartner(coreMessage, startTime) {
260 266 const createdTs = new Date(task.created);
261 267 const queueTime = ((new Date()) - createdTs) / 1000;
262 268 logger.info(`${MODULE_NAME} 7F131334: Got task from CORE`, {
  269 + xid,
263 270 trx_id: task.trx_id,
264 271 destination: task.destination,
265 272 product: task.product,
... ... @@ -269,9 +276,9 @@ function forwardCoreTaskToPartner(coreMessage, startTime) {
269 276  
270 277 taskArchive.get(task, (res) => {
271 278 if (res && partner.advice) {
272   - partner.advice(task);
  279 + partner.advice(task, xid);
273 280 } else {
274   - partner.buy(task);
  281 + partner.buy(task, xid);
275 282 }
276 283 });
277 284 }
... ... @@ -324,6 +331,8 @@ function pullTask() {
324 331 }
325 332 pullTaskLocked = true;
326 333  
  334 + const xid = uniqid();
  335 +
327 336 const bodyOrQs = {
328 337 handler: config.handler_name,
329 338 products: (config.products || []).join(','),
... ... @@ -352,13 +361,13 @@ function pullTask() {
352 361  
353 362 if (config.pull_task_use_post) {
354 363 if (IS_DEBUG) {
355   - logger.verbose(`${MODULE_NAME} CB855B30: PULL TASK using HTTP POST`);
  364 + logger.verbose(`${MODULE_NAME} CB855B30: PULL TASK using HTTP POST`, { xid });
356 365 }
357 366 options.method = 'POST';
358 367 options.form = bodyOrQs;
359 368 } else {
360 369 if (IS_DEBUG) {
361   - logger.verbose(`${MODULE_NAME} BA2EF935: PULL TASK using HTTP GET`);
  370 + logger.verbose(`${MODULE_NAME} BA2EF935: PULL TASK using HTTP GET`, { xid });
362 371 }
363 372 options.method = 'GET';
364 373 options.qs = bodyOrQs;
... ... @@ -366,7 +375,7 @@ function pullTask() {
366 375  
367 376 if (config && config.debug_request_task_to_core) {
368 377 logger.verbose(`${MODULE_NAME} 0642E25C: Requesting task to CORE`, {
369   - url: options.url, method: options.method, body_or_qs: bodyOrQs,
  378 + xid, url: options.url, method: options.method, body_or_qs: bodyOrQs,
370 379 });
371 380 }
372 381  
... ... @@ -377,12 +386,12 @@ function pullTask() {
377 386 const lameLimit = 10 * 1000;
378 387 const deltaTime = new Date() - startTime;
379 388 if (deltaTime > lameLimit) {
380   - logger.warn(`${MODULE_NAME} B892DC43: LAME-PULL: PULL response from CORE exceeds ${lameLimit} secs`, { deltaTime });
  389 + logger.warn(`${MODULE_NAME} B892DC43: LAME-PULL: PULL response from CORE exceeds ${lameLimit} secs`, { xid, deltaTime });
381 390 }
382 391  
383 392 if (error) {
384 393 if (matrix.core_is_healthy) {
385   - logger.warn(`${MODULE_NAME} FB762F4A: Error pulling task from CORE`, { error });
  394 + logger.warn(`${MODULE_NAME} FB762F4A: Error pulling task from CORE`, { xid, error });
386 395 }
387 396 matrix.core_is_healthy = false;
388 397 onNoTask();
... ... @@ -392,6 +401,7 @@ function pullTask() {
392 401 if (response.statusCode !== 200) {
393 402 if (matrix.core_is_healthy) {
394 403 logger.warn(`${MODULE_NAME} 8943EECB: CORE http response status code for pull task is not 200`, {
  404 + xid,
395 405 http_response_status: response.statusCode,
396 406 });
397 407 }
... ... @@ -401,7 +411,7 @@ function pullTask() {
401 411 }
402 412  
403 413 if (!matrix.core_is_healthy) {
404   - logger.verbose(`${MODULE_NAME} 099F5B3C: CORE is healthy`);
  414 + logger.verbose(`${MODULE_NAME} 099F5B3C: CORE is healthy`, { xid });
405 415 }
406 416 matrix.core_is_healthy = true;
407 417  
... ... @@ -414,7 +424,7 @@ function pullTask() {
414 424 return;
415 425 }
416 426  
417   - forwardCoreTaskToPartner(body, startTime);
  427 + forwardCoreTaskToPartner(body, startTime, xid);
418 428 });
419 429 }
420 430  
1 1 {
2 2 "name": "komodo-sdk",
3   - "version": "1.44.0",
  3 + "version": "1.44.1",
4 4 "lockfileVersion": 2,
5 5 "requires": true,
6 6 "packages": {
7 7 "": {
8 8 "name": "komodo-sdk",
9   - "version": "1.44.0",
  9 + "version": "1.44.1",
10 10 "license": "ISC",
11 11 "dependencies": {
12 12 "array-unique": "^0.3.2",
1 1 {
2 2 "name": "komodo-sdk",
3   - "version": "1.44.0",
  3 + "version": "1.44.1",
4 4 "description": "SDK for Komodo",
5 5 "main": "index.js",
6 6 "scripts": {