odsl-javascript-sdk 1.1.3 → 1.1.5
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/package.json +1 -1
- package/src/process.js +13 -3
package/package.json
CHANGED
package/src/process.js
CHANGED
|
@@ -4,14 +4,13 @@ module.exports = class PROCESS {
|
|
|
4
4
|
constructor(p, task) {
|
|
5
5
|
this.process = p;
|
|
6
6
|
this.task = task;
|
|
7
|
-
var cstr = process.env.ODSL_SB_CPM;
|
|
8
|
-
this.serviceBusClient = new ServiceBusClient(cstr);
|
|
9
7
|
this.started = false;
|
|
10
8
|
this.queue_name = process.env.ODSL_STAGE + "/process-execution";
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
async startProcess() {
|
|
14
12
|
if (!this.started) {
|
|
13
|
+
this.serviceBusClient = new ServiceBusClient(process.env.ODSL_SB_CPM);
|
|
15
14
|
console.log("Starting process for task: " + this.task._id);
|
|
16
15
|
var message = new ProcessMessage(this.process, this.task);
|
|
17
16
|
message.status = "start";
|
|
@@ -26,6 +25,7 @@ module.exports = class PROCESS {
|
|
|
26
25
|
message.message = mess;
|
|
27
26
|
console.log(mess);
|
|
28
27
|
await this.updateProcess(message);
|
|
28
|
+
this.serviceBusClient.close();
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
async startPhase(name) {
|
|
@@ -40,8 +40,13 @@ module.exports = class PROCESS {
|
|
|
40
40
|
this.phase.status = status;
|
|
41
41
|
this.phase.message = mess;
|
|
42
42
|
this.phase.timestamp = new Date().toISOString().substring(0,19);
|
|
43
|
-
let level =
|
|
43
|
+
let level = "INFO";
|
|
44
44
|
let lm = new Date().toISOString() + " " + level + " " + mess;
|
|
45
|
+
if (status == "failed") {
|
|
46
|
+
level = "SEVERE";
|
|
47
|
+
lm = new Date().toISOString() + " " + level + " " + mess;
|
|
48
|
+
this.phase.warnings.push(lm);
|
|
49
|
+
}
|
|
45
50
|
this.phase.log.push(lm);
|
|
46
51
|
await this.updateProcess(this.phase);
|
|
47
52
|
}
|
|
@@ -49,6 +54,9 @@ module.exports = class PROCESS {
|
|
|
49
54
|
async logMessage(level, mess) {
|
|
50
55
|
let lm = new Date().toISOString() + " " + level + " " + mess;
|
|
51
56
|
console.log(lm);
|
|
57
|
+
if (level == "WARNING" || level == "SEVERE") {
|
|
58
|
+
this.phase.warnings.push(lm);
|
|
59
|
+
}
|
|
52
60
|
this.phase.log.push(lm);
|
|
53
61
|
await this.updateProcess(this.phase);
|
|
54
62
|
}
|
|
@@ -63,12 +71,14 @@ module.exports = class PROCESS {
|
|
|
63
71
|
}
|
|
64
72
|
var sender = this.serviceBusClient.createSender(this.queue_name);
|
|
65
73
|
await sender.sendMessages(sbm);
|
|
74
|
+
await sender.close();
|
|
66
75
|
}
|
|
67
76
|
}
|
|
68
77
|
|
|
69
78
|
class ProcessMessage {
|
|
70
79
|
constructor(p, t) {
|
|
71
80
|
this.log = [];
|
|
81
|
+
this.warnings = [];
|
|
72
82
|
this.timestamp = new Date().toISOString().substring(0,19);
|
|
73
83
|
this.type = "ProcessMessage";
|
|
74
84
|
this.id = t._id;
|