ws-process 0.3.28 → 0.3.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +38 -20
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -24,7 +24,24 @@ import reducer, { initialState } from './reducer';
|
|
|
24
24
|
import 'url-search-params-polyfill';
|
|
25
25
|
import { cutStringByLength, createSplitPayload } from './lib/split-payload';
|
|
26
26
|
|
|
27
|
-
const local = {
|
|
27
|
+
const local = {
|
|
28
|
+
processes: {},
|
|
29
|
+
wsProcess: initialState,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
local.dispatch = (action) => {
|
|
33
|
+
local.wsProcess = reducer(local.wsProcess, action);
|
|
34
|
+
if (getRef().current) {
|
|
35
|
+
switch (action.type) {
|
|
36
|
+
case storeSplittedData().type:
|
|
37
|
+
case clearDataSplitted().type:
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
getRef().current.setState({ wsProcess: local.wsProcess });
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
28
45
|
|
|
29
46
|
function getType(obj) {
|
|
30
47
|
return Object.prototype.toString.call(obj);
|
|
@@ -359,8 +376,13 @@ function handleResponseHandler(res, getState, isLast = true, isFirst = true) {
|
|
|
359
376
|
res.processID,
|
|
360
377
|
);
|
|
361
378
|
const { resHandler, callback, requestTime } = cProcessItem;
|
|
362
|
-
console.warn('distance:', new Date() - new Date(requestTime), res.processID, prc.count);
|
|
363
379
|
|
|
380
|
+
if(process.env.NODE_ENV === "test"){
|
|
381
|
+
// pass
|
|
382
|
+
}else{
|
|
383
|
+
console.log('%cdistance:', 'color:orange', new Date() - new Date(requestTime), res.processID, prc.count, tryit(()=>res.headers["x-log-id"]));
|
|
384
|
+
}
|
|
385
|
+
|
|
364
386
|
const result = resHandler
|
|
365
387
|
? local.store.dispatch(
|
|
366
388
|
resHandler({
|
|
@@ -517,7 +539,12 @@ function asyncSend(msg) {
|
|
|
517
539
|
},
|
|
518
540
|
validateStatus: () => true,
|
|
519
541
|
});
|
|
520
|
-
|
|
542
|
+
|
|
543
|
+
if(process.env.NODE_ENV === "test"){
|
|
544
|
+
// pass
|
|
545
|
+
}else{
|
|
546
|
+
console.log('%csending message:', 'color:green', httpMSG, msg);
|
|
547
|
+
}
|
|
521
548
|
|
|
522
549
|
return axios(httpMSG).catch((ex) => {
|
|
523
550
|
console.log('%conmessage(converted):', 'color:red', ex);
|
|
@@ -543,7 +570,11 @@ function asyncSend(msg) {
|
|
|
543
570
|
}
|
|
544
571
|
return data;
|
|
545
572
|
}).then((data) => {
|
|
546
|
-
|
|
573
|
+
if(process.env.NODE_ENV === "test"){
|
|
574
|
+
// pass
|
|
575
|
+
}else{
|
|
576
|
+
console.log('%cHTTP.res:', 'color:red', data);
|
|
577
|
+
}
|
|
547
578
|
const processID = tryit(() => data.headers['process-id']) || tryit(() => data.config.headers['bsg-support-process-id']);
|
|
548
579
|
|
|
549
580
|
const newData = {
|
|
@@ -939,7 +970,7 @@ function runProcess(processID, data) {
|
|
|
939
970
|
// const args = leakArguments(arguments, 1);
|
|
940
971
|
|
|
941
972
|
return (dispatch, getState) => {
|
|
942
|
-
console.
|
|
973
|
+
console.debug('run process ', processID);
|
|
943
974
|
return new Promise((resolve, reject) => {
|
|
944
975
|
const { processes } = local.wsProcess;
|
|
945
976
|
|
|
@@ -955,7 +986,7 @@ function runProcess(processID, data) {
|
|
|
955
986
|
if (prc.count === prc.items.length) {
|
|
956
987
|
// process finished
|
|
957
988
|
|
|
958
|
-
console.
|
|
989
|
+
console.debug('process finished ', processID);
|
|
959
990
|
|
|
960
991
|
// const unfinishedProcesses = Object.keys(processes).filter(subKey => {
|
|
961
992
|
// if (processes[subKey].count < processes[subKey].items.length) {
|
|
@@ -1247,20 +1278,7 @@ function init({
|
|
|
1247
1278
|
local.store = store;
|
|
1248
1279
|
local.stage = stage;
|
|
1249
1280
|
local.wsURL = wsURL;
|
|
1250
|
-
|
|
1251
|
-
local.dispatch = (action) => {
|
|
1252
|
-
local.wsProcess = reducer(local.wsProcess, action);
|
|
1253
|
-
if (getRef().current) {
|
|
1254
|
-
switch (action.type) {
|
|
1255
|
-
case storeSplittedData().type:
|
|
1256
|
-
case clearDataSplitted().type:
|
|
1257
|
-
break;
|
|
1258
|
-
default:
|
|
1259
|
-
getRef().current.setState({ wsProcess: local.wsProcess });
|
|
1260
|
-
break;
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
};
|
|
1281
|
+
|
|
1264
1282
|
local.beforeEachProcess = beforeEachProcess || (() => {});
|
|
1265
1283
|
local.afterEachProcess = afterEachProcess || (() => {});
|
|
1266
1284
|
local.beforeAllProcesses = beforeAllProcesses || (() => {});
|