@webda/async 2.1.5 → 2.3.0
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/lib/models.d.ts +48 -7
- package/lib/models.js +59 -1
- package/lib/models.js.map +1 -1
- package/lib/services/asyncjobservice.d.ts +74 -5
- package/lib/services/asyncjobservice.js +124 -26
- package/lib/services/asyncjobservice.js.map +1 -1
- package/lib/services/servicerunner.d.ts +68 -0
- package/lib/services/servicerunner.js +94 -0
- package/lib/services/servicerunner.js.map +1 -0
- package/package.json +7 -6
- package/webda.module.json +347 -3
package/lib/models.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CoreModel } from "@webda/core";
|
|
1
|
+
import { CoreModel, OperationContext } from "@webda/core";
|
|
2
|
+
import { WorkerLogLevel } from "@webda/workout";
|
|
2
3
|
/**
|
|
3
4
|
* Represent an item for processing queue
|
|
4
5
|
*/
|
|
@@ -26,6 +27,17 @@ export interface Job {
|
|
|
26
27
|
* @WebdaModel
|
|
27
28
|
*/
|
|
28
29
|
export default class AsyncAction extends CoreModel {
|
|
30
|
+
/**
|
|
31
|
+
* Set type
|
|
32
|
+
*/
|
|
33
|
+
constructor();
|
|
34
|
+
/**
|
|
35
|
+
* By default AsyncAction are not considered internal
|
|
36
|
+
*
|
|
37
|
+
* Internal: That execute a method or operation of Webda application framework
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
isInternal(): boolean;
|
|
29
41
|
/**
|
|
30
42
|
* Action uuid
|
|
31
43
|
*/
|
|
@@ -33,7 +45,11 @@ export default class AsyncAction extends CoreModel {
|
|
|
33
45
|
/**
|
|
34
46
|
* Current status
|
|
35
47
|
*/
|
|
36
|
-
status: "RUNNING" | "SUCCESS" | "ERROR" | "QUEUED" | "STARTING" | "TIMEOUT";
|
|
48
|
+
status: "RUNNING" | "SUCCESS" | "ERROR" | "QUEUED" | "STARTING" | "TIMEOUT" | "SCHEDULED";
|
|
49
|
+
/**
|
|
50
|
+
* Timestamp when the action was scheduled
|
|
51
|
+
*/
|
|
52
|
+
scheduled?: number;
|
|
37
53
|
/**
|
|
38
54
|
* If an error occured it should contain the message
|
|
39
55
|
*/
|
|
@@ -79,15 +95,40 @@ export default class AsyncAction extends CoreModel {
|
|
|
79
95
|
}
|
|
80
96
|
/**
|
|
81
97
|
* Define a Webda Async Action
|
|
98
|
+
*
|
|
99
|
+
* @WebdaModel
|
|
82
100
|
*/
|
|
83
|
-
export declare class
|
|
101
|
+
export declare class AsyncWebdaAction extends AsyncAction {
|
|
102
|
+
serviceName?: string;
|
|
103
|
+
method?: string;
|
|
104
|
+
logLevel: WorkerLogLevel;
|
|
84
105
|
/**
|
|
85
|
-
*
|
|
106
|
+
*
|
|
107
|
+
* @param serviceName service to call
|
|
108
|
+
* @param method method to call
|
|
109
|
+
* @param arguments to call with the method
|
|
110
|
+
*/
|
|
111
|
+
constructor(serviceName?: string, method?: string, ...args: any[]);
|
|
112
|
+
/**
|
|
113
|
+
* Execute a serviceName.method(...args) so this is internal
|
|
114
|
+
* @returns
|
|
86
115
|
*/
|
|
87
|
-
|
|
116
|
+
isInternal(): boolean;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Operation called asynchronously
|
|
120
|
+
*
|
|
121
|
+
* @WebdaModel
|
|
122
|
+
*/
|
|
123
|
+
export declare class AsyncOperationAction extends AsyncAction {
|
|
124
|
+
operationId: string;
|
|
125
|
+
context: OperationContext;
|
|
126
|
+
logLevel: WorkerLogLevel;
|
|
127
|
+
constructor(operationId: string, context: OperationContext, logLevel?: WorkerLogLevel);
|
|
88
128
|
/**
|
|
89
|
-
*
|
|
129
|
+
* Execute a webda.callOperation(context ,id) so this is internal
|
|
130
|
+
* @returns
|
|
90
131
|
*/
|
|
91
|
-
|
|
132
|
+
isInternal(): boolean;
|
|
92
133
|
}
|
|
93
134
|
export { AsyncAction };
|
package/lib/models.js
CHANGED
|
@@ -4,11 +4,69 @@ import { CoreModel } from "@webda/core";
|
|
|
4
4
|
* @WebdaModel
|
|
5
5
|
*/
|
|
6
6
|
export default class AsyncAction extends CoreModel {
|
|
7
|
+
/**
|
|
8
|
+
* Set type
|
|
9
|
+
*/
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.type = this.constructor.name;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* By default AsyncAction are not considered internal
|
|
16
|
+
*
|
|
17
|
+
* Internal: That execute a method or operation of Webda application framework
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
isInternal() {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
7
23
|
}
|
|
8
24
|
/**
|
|
9
25
|
* Define a Webda Async Action
|
|
26
|
+
*
|
|
27
|
+
* @WebdaModel
|
|
28
|
+
*/
|
|
29
|
+
export class AsyncWebdaAction extends AsyncAction {
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param serviceName service to call
|
|
33
|
+
* @param method method to call
|
|
34
|
+
* @param arguments to call with the method
|
|
35
|
+
*/
|
|
36
|
+
constructor(serviceName, method, ...args) {
|
|
37
|
+
super();
|
|
38
|
+
this.serviceName = serviceName;
|
|
39
|
+
this.method = method;
|
|
40
|
+
this.logLevel = "INFO";
|
|
41
|
+
this.arguments = args;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Execute a serviceName.method(...args) so this is internal
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
isInternal() {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Operation called asynchronously
|
|
53
|
+
*
|
|
54
|
+
* @WebdaModel
|
|
10
55
|
*/
|
|
11
|
-
export class
|
|
56
|
+
export class AsyncOperationAction extends AsyncAction {
|
|
57
|
+
constructor(operationId, context, logLevel = "INFO") {
|
|
58
|
+
super();
|
|
59
|
+
this.operationId = operationId;
|
|
60
|
+
this.context = context;
|
|
61
|
+
this.logLevel = logLevel;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Execute a webda.callOperation(context ,id) so this is internal
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
isInternal() {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
12
70
|
}
|
|
13
71
|
export { AsyncAction };
|
|
14
72
|
//# sourceMappingURL=models.js.map
|
package/lib/models.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,aAAa,CAAC;AA0B1D;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,SAAS;IAChD;;OAEG;IACH;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACH,UAAU;QACR,OAAO,KAAK,CAAC;IACf,CAAC;CAgEF;AAED;;;;GAIG;AACH,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAE/C;;;;;OAKG;IACH,YAAmB,WAAoB,EAAS,MAAe,EAAE,GAAG,IAAW;QAC7E,KAAK,EAAE,CAAC;QADS,gBAAW,GAAX,WAAW,CAAS;QAAS,WAAM,GAAN,MAAM,CAAS;QAPxD,aAAQ,GAAmB,MAAM,CAAC;QASvC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,UAAU;QACR,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACnD,YAAmB,WAAmB,EAAS,OAAyB,EAAS,WAA2B,MAAM;QAChH,KAAK,EAAE,CAAC;QADS,gBAAW,GAAX,WAAW,CAAQ;QAAS,YAAO,GAAP,OAAO,CAAkB;QAAS,aAAQ,GAAR,QAAQ,CAAyB;IAElH,CAAC;IAED;;;OAGG;IACH,UAAU;QACR,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CloudBinary, Context, Queue, RequestFilter, Service, ServiceParameters, Store } from "@webda/core";
|
|
2
|
-
import { AsyncAction, AsyncActionQueueItem } from "../models.js";
|
|
1
|
+
import { CancelableLoopPromise, CloudBinary, Context, CronDefinition, Queue, RequestFilter, Service, ServiceParameters, Store } from "@webda/core";
|
|
2
|
+
import { AsyncAction, AsyncActionQueueItem, AsyncWebdaAction } from "../models.js";
|
|
3
3
|
import { Runner } from "./runner.js";
|
|
4
4
|
/**
|
|
5
5
|
* Represent a Job information as you will find in env
|
|
@@ -55,6 +55,35 @@ export declare class AsyncJobServiceParameters extends ServiceParameters {
|
|
|
55
55
|
* Limit the maximum number of jobs running in //
|
|
56
56
|
*/
|
|
57
57
|
concurrencyLimit?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Define if we should only use an http hook and not rely on store for AsyncOperation
|
|
60
|
+
*
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
onlyHttpHook?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Include Cron annotation to launch them as AsyncOperationAction
|
|
66
|
+
*
|
|
67
|
+
* @default true
|
|
68
|
+
*/
|
|
69
|
+
includeCron?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Schedule action resolution
|
|
72
|
+
*
|
|
73
|
+
* If set to 1000ms, you can schedule action per second
|
|
74
|
+
* by default it resolve per minute
|
|
75
|
+
*
|
|
76
|
+
* @default 60000
|
|
77
|
+
*/
|
|
78
|
+
schedulerResolution?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Limit the number of lines of logs available for an async action
|
|
81
|
+
*
|
|
82
|
+
* If you need to store large amount of logs then you should use the CloudWatchLogger or similar logger
|
|
83
|
+
*
|
|
84
|
+
* @default 500
|
|
85
|
+
*/
|
|
86
|
+
logsLimit: number;
|
|
58
87
|
constructor(params: any);
|
|
59
88
|
}
|
|
60
89
|
/**
|
|
@@ -107,6 +136,14 @@ export default class AsyncJobService<T extends AsyncJobServiceParameters = Async
|
|
|
107
136
|
* Only updates specific fields: status, errorMessage, statusDetails, results, logs (appending)
|
|
108
137
|
*/
|
|
109
138
|
protected statusHook(context: Context): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Update the async action from hook
|
|
141
|
+
* @param action
|
|
142
|
+
* @param body
|
|
143
|
+
* @param lastUpdate
|
|
144
|
+
* @returns
|
|
145
|
+
*/
|
|
146
|
+
protected updateAction(action: AsyncAction, body: Partial<AsyncAction>, lastUpdate?: number): Promise<AsyncAction>;
|
|
110
147
|
/**
|
|
111
148
|
* Worker
|
|
112
149
|
*
|
|
@@ -117,13 +154,20 @@ export default class AsyncJobService<T extends AsyncJobServiceParameters = Async
|
|
|
117
154
|
* Handle one event from the queue and launch the job
|
|
118
155
|
* @param event
|
|
119
156
|
*/
|
|
120
|
-
protected handleEvent(event: AsyncActionQueueItem): Promise<
|
|
157
|
+
protected handleEvent(event: AsyncActionQueueItem): Promise<any>;
|
|
121
158
|
/**
|
|
122
159
|
* Launch the action asynchronously
|
|
123
160
|
* @param action
|
|
124
161
|
* @returns
|
|
125
162
|
*/
|
|
126
|
-
launchAction(action: AsyncAction): Promise<
|
|
163
|
+
launchAction(action: AsyncAction): Promise<any>;
|
|
164
|
+
/**
|
|
165
|
+
* Schedule action for later execution
|
|
166
|
+
*
|
|
167
|
+
* @param action
|
|
168
|
+
* @param timestamp
|
|
169
|
+
*/
|
|
170
|
+
scheduleAction(action: AsyncAction, timestamp: number): Promise<void>;
|
|
127
171
|
/**
|
|
128
172
|
* Return headers to request status hook
|
|
129
173
|
*
|
|
@@ -133,9 +177,34 @@ export default class AsyncJobService<T extends AsyncJobServiceParameters = Async
|
|
|
133
177
|
getHeaders(jobInfo: JobInfo): {
|
|
134
178
|
[key: string]: string;
|
|
135
179
|
};
|
|
180
|
+
/**
|
|
181
|
+
* Post hook to a remote url or use local store to update status
|
|
182
|
+
* @param jobInfo
|
|
183
|
+
* @param message
|
|
184
|
+
* @returns
|
|
185
|
+
*/
|
|
186
|
+
postHook(jobInfo: JobInfo, message: any): Promise<AsyncWebdaAction>;
|
|
187
|
+
/**
|
|
188
|
+
* Launch a service.method as an AsyncAction
|
|
189
|
+
* @param serviceName
|
|
190
|
+
* @param method
|
|
191
|
+
* @param args
|
|
192
|
+
*/
|
|
193
|
+
launchAsAsyncAction(serviceName: string, method: string, ...args: any[]): Promise<any>;
|
|
136
194
|
/**
|
|
137
195
|
* Wrap async job and call the job status hook
|
|
138
196
|
*/
|
|
139
|
-
|
|
197
|
+
runAsyncOperationAction(jobInfo?: JobInfo): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Get the cron callback function
|
|
200
|
+
* @param cron
|
|
201
|
+
* @returns
|
|
202
|
+
*/
|
|
203
|
+
getCronExecutor(cron: CronDefinition): () => Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Manage scheduled actions and crontab actions
|
|
206
|
+
* @returns
|
|
207
|
+
*/
|
|
208
|
+
scheduler(): CancelableLoopPromise;
|
|
140
209
|
}
|
|
141
210
|
export { AsyncJobService };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Service, ServiceParameters } from "@webda/core";
|
|
1
|
+
import { CancelableLoopPromise, Core, CronService, Service, ServiceParameters } from "@webda/core";
|
|
2
2
|
import axios from "axios";
|
|
3
3
|
import * as crypto from "crypto";
|
|
4
|
+
import { schedule as crontabSchedule } from "node-cron";
|
|
4
5
|
import { v4 as uuidv4 } from "uuid";
|
|
6
|
+
import { AsyncWebdaAction } from "../models.js";
|
|
5
7
|
import { Runner } from "./runner.js";
|
|
6
8
|
/**
|
|
7
9
|
* @inheritdoc
|
|
@@ -13,6 +15,10 @@ export class AsyncJobServiceParameters extends ServiceParameters {
|
|
|
13
15
|
this.queue ?? (this.queue = "AsyncActionsQueue");
|
|
14
16
|
this.store ?? (this.store = "AsyncActions");
|
|
15
17
|
this.runners ?? (this.runners = []);
|
|
18
|
+
this.schedulerResolution ?? (this.schedulerResolution = 60000);
|
|
19
|
+
this.onlyHttpHook ?? (this.onlyHttpHook = false);
|
|
20
|
+
this.includeCron ?? (this.includeCron = true);
|
|
21
|
+
this.logsLimit ?? (this.logsLimit = 500);
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
24
|
/**
|
|
@@ -33,7 +39,7 @@ export default class AsyncJobService extends Service {
|
|
|
33
39
|
resolve() {
|
|
34
40
|
super.resolve();
|
|
35
41
|
this.queue = this.getService(this.parameters.queue);
|
|
36
|
-
if (!this.queue) {
|
|
42
|
+
if (!this.queue && !this.parameters.localLaunch) {
|
|
37
43
|
throw new Error(`AsyncService requires a valid queue. '${this.parameters.queue}' is invalid`);
|
|
38
44
|
}
|
|
39
45
|
this.store = this.getService(this.parameters.store);
|
|
@@ -119,17 +125,28 @@ export default class AsyncJobService extends Service {
|
|
|
119
125
|
* Only updates specific fields: status, errorMessage, statusDetails, results, logs (appending)
|
|
120
126
|
*/
|
|
121
127
|
async statusHook(context) {
|
|
122
|
-
|
|
128
|
+
let action = await this.verifyJobRequest(context);
|
|
123
129
|
const body = await context.getRequestBody();
|
|
124
|
-
action
|
|
130
|
+
action = await this.updateAction(action, body, Number.parseInt(context.getHttpContext().getUniqueHeader("X-Job-Time")) || 0);
|
|
131
|
+
context.write({ ...action, logs: undefined, statusDetails: undefined });
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Update the async action from hook
|
|
135
|
+
* @param action
|
|
136
|
+
* @param body
|
|
137
|
+
* @param lastUpdate
|
|
138
|
+
* @returns
|
|
139
|
+
*/
|
|
140
|
+
async updateAction(action, body, lastUpdate = 0) {
|
|
141
|
+
action._lastJobUpdate = lastUpdate;
|
|
125
142
|
if (Date.now() - action._lastJobUpdate > 60) {
|
|
126
143
|
action._lastJobUpdate = Date.now();
|
|
127
144
|
}
|
|
128
145
|
if (body.logs && Array.isArray(body.logs)) {
|
|
129
146
|
action.logs.push(...body.logs);
|
|
130
147
|
// Prevent having too much logs
|
|
131
|
-
if (action.logs.length >
|
|
132
|
-
action.logs = action.logs.slice(-
|
|
148
|
+
if (action.logs.length > this.parameters.logsLimit) {
|
|
149
|
+
action.logs = action.logs.slice(-1 * this.parameters.logsLimit);
|
|
133
150
|
}
|
|
134
151
|
}
|
|
135
152
|
["status", "errorMessage", "statusDetails", "results"].forEach(k => {
|
|
@@ -138,8 +155,8 @@ export default class AsyncJobService extends Service {
|
|
|
138
155
|
action[k] = body[k];
|
|
139
156
|
}
|
|
140
157
|
});
|
|
141
|
-
await this.store.
|
|
142
|
-
|
|
158
|
+
await this.store.patch(action, true, null);
|
|
159
|
+
return action;
|
|
143
160
|
}
|
|
144
161
|
/**
|
|
145
162
|
* Worker
|
|
@@ -174,23 +191,23 @@ export default class AsyncJobService extends Service {
|
|
|
174
191
|
uuid: event.uuid,
|
|
175
192
|
status: "ERROR",
|
|
176
193
|
errorMessage: `No runner found for the job`
|
|
177
|
-
});
|
|
194
|
+
}, null);
|
|
178
195
|
return;
|
|
179
196
|
}
|
|
180
197
|
await this.store.patch({
|
|
181
198
|
uuid: event.uuid,
|
|
182
199
|
status: "STARTING"
|
|
183
|
-
});
|
|
200
|
+
}, null);
|
|
184
201
|
const action = await this.store.get(event.uuid);
|
|
185
202
|
const info = {
|
|
186
203
|
JOB_SECRET_KEY: action.__secretKey,
|
|
187
204
|
JOB_ID: action.getUuid(),
|
|
188
|
-
JOB_HOOK: this.getWebda().getApiUrl(this.parameters.url),
|
|
205
|
+
JOB_HOOK: this.parameters.onlyHttpHook || !action.isInternal() ? this.getWebda().getApiUrl(this.parameters.url) : "store",
|
|
189
206
|
JOB_ORCHESTRATOR: this.getName()
|
|
190
207
|
};
|
|
191
|
-
await
|
|
192
|
-
|
|
193
|
-
|
|
208
|
+
let job = await selectedRunner.launchAction(action, info);
|
|
209
|
+
await action.patch({ job }, null);
|
|
210
|
+
return job.promise || Promise.resolve();
|
|
194
211
|
}
|
|
195
212
|
/**
|
|
196
213
|
* Launch the action asynchronously
|
|
@@ -207,6 +224,19 @@ export default class AsyncJobService extends Service {
|
|
|
207
224
|
}
|
|
208
225
|
return this.queue.sendMessage({ uuid: action.getUuid(), __secretKey: action.__secretKey, type: action.type });
|
|
209
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Schedule action for later execution
|
|
229
|
+
*
|
|
230
|
+
* @param action
|
|
231
|
+
* @param timestamp
|
|
232
|
+
*/
|
|
233
|
+
async scheduleAction(action, timestamp) {
|
|
234
|
+
action.status = "SCHEDULED";
|
|
235
|
+
action.type = action.constructor.name;
|
|
236
|
+
// Schedule based on the scheduler resolution
|
|
237
|
+
action.scheduled = timestamp - (timestamp % this.parameters.schedulerResolution);
|
|
238
|
+
await this.store.save(action);
|
|
239
|
+
}
|
|
210
240
|
/**
|
|
211
241
|
* Return headers to request status hook
|
|
212
242
|
*
|
|
@@ -224,10 +254,37 @@ export default class AsyncJobService extends Service {
|
|
|
224
254
|
.digest("hex");
|
|
225
255
|
return res;
|
|
226
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* Post hook to a remote url or use local store to update status
|
|
259
|
+
* @param jobInfo
|
|
260
|
+
* @param message
|
|
261
|
+
* @returns
|
|
262
|
+
*/
|
|
263
|
+
async postHook(jobInfo, message) {
|
|
264
|
+
// Http allow to break paradigm between the executor and the orchestrator
|
|
265
|
+
if (jobInfo.JOB_HOOK.startsWith("http")) {
|
|
266
|
+
return (await axios.post(jobInfo.JOB_HOOK, message, {
|
|
267
|
+
headers: this.getHeaders(jobInfo)
|
|
268
|
+
})).data;
|
|
269
|
+
}
|
|
270
|
+
else if (jobInfo.JOB_HOOK === "store") {
|
|
271
|
+
// If executor and orchestrator runs within same privilege it simplify the infrastructure
|
|
272
|
+
return this.updateAction(await this.store.get(jobInfo.JOB_ID), message);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Launch a service.method as an AsyncAction
|
|
277
|
+
* @param serviceName
|
|
278
|
+
* @param method
|
|
279
|
+
* @param args
|
|
280
|
+
*/
|
|
281
|
+
async launchAsAsyncAction(serviceName, method, ...args) {
|
|
282
|
+
return this.launchAction(new AsyncWebdaAction(serviceName, method, ...args));
|
|
283
|
+
}
|
|
227
284
|
/**
|
|
228
285
|
* Wrap async job and call the job status hook
|
|
229
286
|
*/
|
|
230
|
-
async
|
|
287
|
+
async runAsyncOperationAction(jobInfo) {
|
|
231
288
|
// Get it from environment
|
|
232
289
|
if (jobInfo === undefined) {
|
|
233
290
|
jobInfo = {};
|
|
@@ -238,22 +295,24 @@ export default class AsyncJobService extends Service {
|
|
|
238
295
|
}
|
|
239
296
|
// Ensure correct context
|
|
240
297
|
if (!jobInfo.JOB_ORCHESTRATOR || !jobInfo.JOB_ID || !jobInfo.JOB_SECRET_KEY || !jobInfo.JOB_HOOK) {
|
|
298
|
+
this.log("ERROR", "Cannot run AsyncAction without context");
|
|
241
299
|
throw new Error("Cannot run AsyncAction without context");
|
|
242
300
|
}
|
|
243
301
|
// If we are not the target redirect to the right one
|
|
244
302
|
if (jobInfo.JOB_ORCHESTRATOR !== this.getName()) {
|
|
245
|
-
|
|
303
|
+
this.log("DEBUG", `Passing jobInfo ${jobInfo} to targeted service`);
|
|
304
|
+
return this.getService(jobInfo.JOB_ORCHESTRATOR).runAsyncOperationAction(jobInfo);
|
|
246
305
|
}
|
|
306
|
+
this.log("DEBUG", "Getting action to execute from hook", jobInfo);
|
|
247
307
|
// Get action info by calling the hook
|
|
248
|
-
let action =
|
|
308
|
+
let action = await this.postHook(jobInfo, {
|
|
249
309
|
agent: {
|
|
250
310
|
...Runner.getAgentInfo(),
|
|
251
311
|
nodeVersion: process.version
|
|
252
312
|
},
|
|
253
313
|
status: "RUNNING"
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
})).data;
|
|
314
|
+
});
|
|
315
|
+
this.log("DEBUG", "Action received", action.serviceName, action.method, action.arguments);
|
|
257
316
|
let results;
|
|
258
317
|
try {
|
|
259
318
|
// Check it contains the right info
|
|
@@ -274,20 +333,59 @@ export default class AsyncJobService extends Service {
|
|
|
274
333
|
}
|
|
275
334
|
catch (err) {
|
|
276
335
|
// Job is in error
|
|
277
|
-
await
|
|
336
|
+
await this.postHook(jobInfo, {
|
|
278
337
|
errorMessage: err?.message,
|
|
279
338
|
status: "ERROR"
|
|
280
|
-
}, {
|
|
281
|
-
headers: this.getHeaders(jobInfo)
|
|
282
339
|
});
|
|
283
340
|
return;
|
|
284
341
|
}
|
|
285
342
|
// Update status
|
|
286
|
-
await
|
|
343
|
+
await this.postHook(jobInfo, {
|
|
287
344
|
results,
|
|
288
345
|
status: "SUCCESS"
|
|
289
|
-
}
|
|
290
|
-
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Get the cron callback function
|
|
350
|
+
* @param cron
|
|
351
|
+
* @returns
|
|
352
|
+
*/
|
|
353
|
+
getCronExecutor(cron) {
|
|
354
|
+
return async () => {
|
|
355
|
+
try {
|
|
356
|
+
this.log("INFO", `Execute cron ${cron.cron}: ${cron.serviceName}.${cron.method}(...) # ${cron.description} as an AsyncOperationAction`);
|
|
357
|
+
await this.launchAction(new AsyncWebdaAction(cron.serviceName, cron.method, cron.args));
|
|
358
|
+
}
|
|
359
|
+
catch (err) {
|
|
360
|
+
this.log("ERROR", `Execution error cron ${cron.cron}: ${cron.serviceName}.${cron.method}(...) # ${cron.description} - ${err}`);
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Manage scheduled actions and crontab actions
|
|
366
|
+
* @returns
|
|
367
|
+
*/
|
|
368
|
+
scheduler() {
|
|
369
|
+
// Map cron to an AsyncOperationAction
|
|
370
|
+
// It allows you to keep a trace of the cron execution in the AsyncAction
|
|
371
|
+
if (this.parameters.includeCron) {
|
|
372
|
+
CronService.loadAnnotations(this._webda.getServices()).forEach(cron => {
|
|
373
|
+
this.log("INFO", `Schedule cron ${cron.cron}: ${cron.serviceName}.${cron.method}(...) # ${cron.description}`);
|
|
374
|
+
crontabSchedule(cron.cron, this.getCronExecutor(cron));
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
// Every schedulerResolution will check for scheduled task
|
|
378
|
+
return new CancelableLoopPromise(async () => {
|
|
379
|
+
let time = Date.now();
|
|
380
|
+
time -= time % this.parameters.schedulerResolution;
|
|
381
|
+
// Queue all actions
|
|
382
|
+
await Promise.all((await this.store.query(`status = 'SCHEDULED' AND scheduled < ${time + 1}`)).results.map(a => this.launchAction(a)));
|
|
383
|
+
time += this.parameters.schedulerResolution;
|
|
384
|
+
// Wait for next scheduler resolution
|
|
385
|
+
if (time > Date.now()) {
|
|
386
|
+
await Core.sleep(time - Date.now());
|
|
387
|
+
/* c8 ignore next */
|
|
388
|
+
}
|
|
291
389
|
});
|
|
292
390
|
}
|
|
293
391
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncjobservice.js","sourceRoot":"","sources":["../../src/services/asyncjobservice.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,OAAO,EAAE,iBAAiB,EAAS,MAAM,aAAa,CAAC;AAC5G,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAYlC;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,iBAAiB;IA2C9D,YAAY,MAAW;QACrB,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,GAAG,KAAR,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 -0,0 +1,68 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { MemoryLogger, WorkerLogLevel, WorkerMessage, WorkerOutput } from "@webda/workout";
|
|
3
|
+
import { AsyncAction } from "../models.js";
|
|
4
|
+
import { JobInfo } from "./asyncjobservice.js";
|
|
5
|
+
import { AgentInfo, Runner, RunnerParameters } from "./runner.js";
|
|
6
|
+
/**
|
|
7
|
+
* Type of action returned by LocalRunner
|
|
8
|
+
*/
|
|
9
|
+
export interface ServiceAction {
|
|
10
|
+
/**
|
|
11
|
+
* Info on the server running it
|
|
12
|
+
*/
|
|
13
|
+
agent: AgentInfo;
|
|
14
|
+
/**
|
|
15
|
+
* Promise of the implementation
|
|
16
|
+
*
|
|
17
|
+
* Useful for unit test
|
|
18
|
+
*/
|
|
19
|
+
promise: Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Keep log in memory and save it to the action object every 5s
|
|
23
|
+
*/
|
|
24
|
+
export declare class ActionMemoryLogger extends MemoryLogger {
|
|
25
|
+
protected action: AsyncAction;
|
|
26
|
+
logSaveDelay: number;
|
|
27
|
+
format?: string;
|
|
28
|
+
protected timeout: NodeJS.Timeout;
|
|
29
|
+
constructor(output: WorkerOutput, level: WorkerLogLevel, limit: number, action: AsyncAction, logSaveDelay: number, format?: string);
|
|
30
|
+
onMessage(msg: WorkerMessage): void;
|
|
31
|
+
save(): Promise<void>;
|
|
32
|
+
saveAndClose(): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Add the log format to capture
|
|
36
|
+
*/
|
|
37
|
+
export declare class ServiceRunnerParameters extends RunnerParameters {
|
|
38
|
+
/**
|
|
39
|
+
* Define the log format
|
|
40
|
+
*
|
|
41
|
+
* @default ConsoleLoggerDefaultFormat
|
|
42
|
+
*/
|
|
43
|
+
logFormat?: string;
|
|
44
|
+
/**
|
|
45
|
+
* How long before saving logs (in ms)
|
|
46
|
+
*
|
|
47
|
+
* @default 5000
|
|
48
|
+
*/
|
|
49
|
+
logSaveDelay?: number;
|
|
50
|
+
constructor(params: any);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Run a Job locally on the server by spawning a child process
|
|
54
|
+
*
|
|
55
|
+
* @WebdaModda
|
|
56
|
+
*/
|
|
57
|
+
export default class ServiceRunner<T extends ServiceRunnerParameters = ServiceRunnerParameters> extends Runner<T> {
|
|
58
|
+
/**
|
|
59
|
+
* Load parameters
|
|
60
|
+
* @param params
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
loadParameters(params: any): ServiceRunnerParameters;
|
|
64
|
+
/**
|
|
65
|
+
* @inheritdoc
|
|
66
|
+
*/
|
|
67
|
+
launchAction(action: AsyncAction, info: JobInfo): Promise<ServiceAction>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ConsoleLogger, MemoryLogger } from "@webda/workout";
|
|
2
|
+
import { Runner, RunnerParameters } from "./runner.js";
|
|
3
|
+
/**
|
|
4
|
+
* Keep log in memory and save it to the action object every 5s
|
|
5
|
+
*/
|
|
6
|
+
export class ActionMemoryLogger extends MemoryLogger {
|
|
7
|
+
constructor(output, level, limit, action, logSaveDelay, format) {
|
|
8
|
+
super(output, level, limit);
|
|
9
|
+
this.action = action;
|
|
10
|
+
this.logSaveDelay = logSaveDelay;
|
|
11
|
+
this.format = format;
|
|
12
|
+
}
|
|
13
|
+
onMessage(msg) {
|
|
14
|
+
super.onMessage(msg);
|
|
15
|
+
if (!this.timeout) {
|
|
16
|
+
setTimeout(() => this.save(), this.logSaveDelay);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
save() {
|
|
20
|
+
this.timeout = undefined;
|
|
21
|
+
return this.action.patch({ logs: this.getLogs().map(msg => ConsoleLogger.format(msg, this.format)) }, null);
|
|
22
|
+
}
|
|
23
|
+
async saveAndClose() {
|
|
24
|
+
this.close();
|
|
25
|
+
return this.save();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Add the log format to capture
|
|
30
|
+
*/
|
|
31
|
+
export class ServiceRunnerParameters extends RunnerParameters {
|
|
32
|
+
constructor(params) {
|
|
33
|
+
super(params);
|
|
34
|
+
this.logSaveDelay ?? (this.logSaveDelay = 5000);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Run a Job locally on the server by spawning a child process
|
|
39
|
+
*
|
|
40
|
+
* @WebdaModda
|
|
41
|
+
*/
|
|
42
|
+
export default class ServiceRunner extends Runner {
|
|
43
|
+
/**
|
|
44
|
+
* Load parameters
|
|
45
|
+
* @param params
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
loadParameters(params) {
|
|
49
|
+
return new ServiceRunnerParameters(params);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @inheritdoc
|
|
53
|
+
*/
|
|
54
|
+
async launchAction(action, info) {
|
|
55
|
+
if (action.type !== "AsyncWebdaAction" && action.type !== "AsyncOperationAction") {
|
|
56
|
+
this.log("ERROR", "Can only handle AsyncWebdaAction or AsyncOperationAction got", action.type);
|
|
57
|
+
throw new Error("Can only handle AsyncWebdaAction or AsyncOperationAction got " + action.type);
|
|
58
|
+
}
|
|
59
|
+
// Launch within current process
|
|
60
|
+
let promise = (async (action) => {
|
|
61
|
+
let logger;
|
|
62
|
+
try {
|
|
63
|
+
await action.patch({ status: "RUNNING" });
|
|
64
|
+
this.log("INFO", "Job", action.getUuid(), "started");
|
|
65
|
+
// Inject a MemoryLogger to capture and report any logs
|
|
66
|
+
logger = new ActionMemoryLogger(this.getWebda().getWorkerOutput(), action.logLevel, this.getService(info.JOB_ORCHESTRATOR)?.getParameters().logsLimit || 5000, action, this.parameters.logSaveDelay, this.parameters.logFormat);
|
|
67
|
+
if (action.type === "AsyncWebdaAction") {
|
|
68
|
+
const webdaAction = action;
|
|
69
|
+
await this.getService(webdaAction.serviceName)[webdaAction.method](...(webdaAction.arguments || []));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const operationAction = action;
|
|
73
|
+
await this.getWebda().callOperation(operationAction.context, operationAction.operationId);
|
|
74
|
+
}
|
|
75
|
+
await logger.saveAndClose();
|
|
76
|
+
await action.patch({ status: "SUCCESS" }, null);
|
|
77
|
+
this.log("INFO", "Job", action.getUuid(), "finished");
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
await logger?.saveAndClose();
|
|
81
|
+
await action.patch({
|
|
82
|
+
status: "ERROR",
|
|
83
|
+
errorMessage: JSON.stringify(err, Object.getOwnPropertyNames(err))
|
|
84
|
+
}, null);
|
|
85
|
+
this.log("ERROR", "Job", action.getUuid(), "errored", err);
|
|
86
|
+
}
|
|
87
|
+
})(action);
|
|
88
|
+
return {
|
|
89
|
+
agent: Runner.getAgentInfo(),
|
|
90
|
+
promise
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=servicerunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"servicerunner.js","sourceRoot":"","sources":["../../src/services/servicerunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAA+C,MAAM,gBAAgB,CAAC;AAG1G,OAAO,EAAa,MAAM,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAkB/D;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,YAAY;IAGlD,YACE,MAAoB,EACpB,KAAqB,EACrB,KAAa,EACH,MAAmB,EACtB,YAAoB,EACpB,MAAe;QAEtB,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAJlB,WAAM,GAAN,MAAM,CAAa;QACtB,iBAAY,GAAZ,YAAY,CAAQ;QACpB,WAAM,GAAN,MAAM,CAAS;IAGxB,CAAC;IAED,SAAS,CAAC,GAAkB;QAC1B,KAAK,CAAC,SAAS,CAAC,GAAG,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E,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC;aACvD;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,MAAM,EAAE,YAAY,EAAE,CAAC;gBAC7B,MAAM,MAAM,CAAC,KAAK,CAChB;oBACE,MAAM,EAAE,OAAO;oBACf,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;iBACnE,EACD,IAAI,CACL,CAAC;gBACF,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;aAC5D;QACH,CAAC,CAAC,CAA0C,MAAM,CAAC,CAAC;QAEpD,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE;YAC5B,OAAO;SACR,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webda/async",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Async System",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc-esm",
|
|
8
8
|
"build:module": "webda build",
|
|
9
|
+
"build:watch": "webda build --watch",
|
|
9
10
|
"pretest": "npm run build",
|
|
10
11
|
"test": "c8 mocha --recursive --exit --timeout=100000 -r ../../node_modules/ts-node/register src/**/*.spec.ts",
|
|
11
12
|
"run": "node core"
|
|
@@ -19,17 +20,17 @@
|
|
|
19
20
|
"package.json"
|
|
20
21
|
],
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@webda/core": "^2.
|
|
23
|
+
"@webda/core": "^2.3.0",
|
|
23
24
|
"axios": "^1.1.3"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"@types/node": "14.6.0",
|
|
27
|
-
"@webda/tsc-esm": "^1.0.
|
|
28
|
+
"@webda/tsc-esm": "^1.0.2",
|
|
28
29
|
"mocha": "^10.0.0",
|
|
29
|
-
"sinon": "^
|
|
30
|
+
"sinon": "^15.0.0",
|
|
30
31
|
"source-map-support": "^0.5.19",
|
|
31
32
|
"ts-node": "^10.2.0",
|
|
32
|
-
"typescript": "~4.
|
|
33
|
+
"typescript": "~4.9.3"
|
|
33
34
|
},
|
|
34
35
|
"c8": {
|
|
35
36
|
"report-dir": "./reports",
|
|
@@ -61,5 +62,5 @@
|
|
|
61
62
|
"engines": {
|
|
62
63
|
"node": ">=14.6.0"
|
|
63
64
|
},
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "fcdb5181ae9353dd8618017fae07ca75203bb1ad"
|
|
65
66
|
}
|
package/webda.module.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"moddas": {
|
|
3
3
|
"webda/asyncjobservice": "lib/services/asyncjobservice:default",
|
|
4
|
-
"webda/localrunner": "lib/services/localrunner:default"
|
|
4
|
+
"webda/localrunner": "lib/services/localrunner:default",
|
|
5
|
+
"webda/servicerunner": "lib/services/servicerunner:default"
|
|
5
6
|
},
|
|
6
7
|
"beans": {},
|
|
7
8
|
"models": {
|
|
8
|
-
"webda/asyncaction": "lib/models:default"
|
|
9
|
+
"webda/asyncaction": "lib/models:default",
|
|
10
|
+
"webda/asyncoperationaction": "lib/models:AsyncOperationAction",
|
|
11
|
+
"webda/asyncwebdaaction": "lib/models:AsyncWebdaAction"
|
|
9
12
|
},
|
|
10
13
|
"deployers": {},
|
|
11
14
|
"schemas": {
|
|
@@ -36,10 +39,15 @@
|
|
|
36
39
|
"ERROR",
|
|
37
40
|
"QUEUED",
|
|
38
41
|
"STARTING",
|
|
39
|
-
"TIMEOUT"
|
|
42
|
+
"TIMEOUT",
|
|
43
|
+
"SCHEDULED"
|
|
40
44
|
],
|
|
41
45
|
"description": "Current status"
|
|
42
46
|
},
|
|
47
|
+
"scheduled": {
|
|
48
|
+
"type": "number",
|
|
49
|
+
"description": "Timestamp when the action was scheduled"
|
|
50
|
+
},
|
|
43
51
|
"errorMessage": {
|
|
44
52
|
"type": "string",
|
|
45
53
|
"description": "If an error occured it should contain the message"
|
|
@@ -91,6 +99,280 @@
|
|
|
91
99
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
92
100
|
"title": "AsyncAction"
|
|
93
101
|
},
|
|
102
|
+
"webda/asyncwebdaaction": {
|
|
103
|
+
"type": "object",
|
|
104
|
+
"properties": {
|
|
105
|
+
"_creationDate": {
|
|
106
|
+
"type": "string",
|
|
107
|
+
"format": "date-time",
|
|
108
|
+
"description": "Creation date",
|
|
109
|
+
"readOnly": true
|
|
110
|
+
},
|
|
111
|
+
"_lastUpdate": {
|
|
112
|
+
"type": "string",
|
|
113
|
+
"format": "date-time",
|
|
114
|
+
"description": "Last update date",
|
|
115
|
+
"readOnly": true
|
|
116
|
+
},
|
|
117
|
+
"uuid": {
|
|
118
|
+
"type": "string",
|
|
119
|
+
"description": "Action uuid"
|
|
120
|
+
},
|
|
121
|
+
"status": {
|
|
122
|
+
"type": "string",
|
|
123
|
+
"enum": [
|
|
124
|
+
"RUNNING",
|
|
125
|
+
"SUCCESS",
|
|
126
|
+
"ERROR",
|
|
127
|
+
"QUEUED",
|
|
128
|
+
"STARTING",
|
|
129
|
+
"TIMEOUT",
|
|
130
|
+
"SCHEDULED"
|
|
131
|
+
],
|
|
132
|
+
"description": "Current status"
|
|
133
|
+
},
|
|
134
|
+
"scheduled": {
|
|
135
|
+
"type": "number",
|
|
136
|
+
"description": "Timestamp when the action was scheduled"
|
|
137
|
+
},
|
|
138
|
+
"errorMessage": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"description": "If an error occured it should contain the message"
|
|
141
|
+
},
|
|
142
|
+
"job": {
|
|
143
|
+
"type": "object",
|
|
144
|
+
"description": "Job information"
|
|
145
|
+
},
|
|
146
|
+
"_lastJobUpdate": {
|
|
147
|
+
"type": "number",
|
|
148
|
+
"description": "Last time the job was updated",
|
|
149
|
+
"readOnly": true
|
|
150
|
+
},
|
|
151
|
+
"results": {
|
|
152
|
+
"description": "Results from the job"
|
|
153
|
+
},
|
|
154
|
+
"statusDetails": {
|
|
155
|
+
"description": "Job current status"
|
|
156
|
+
},
|
|
157
|
+
"type": {
|
|
158
|
+
"type": "string"
|
|
159
|
+
},
|
|
160
|
+
"arguments": {
|
|
161
|
+
"type": "array",
|
|
162
|
+
"items": {}
|
|
163
|
+
},
|
|
164
|
+
"logs": {
|
|
165
|
+
"type": "array",
|
|
166
|
+
"items": {
|
|
167
|
+
"type": "string"
|
|
168
|
+
},
|
|
169
|
+
"description": "Current logs"
|
|
170
|
+
},
|
|
171
|
+
"action": {
|
|
172
|
+
"type": "string",
|
|
173
|
+
"description": "Expected action for the job\n\nIt should be a verb"
|
|
174
|
+
},
|
|
175
|
+
"logLevel": {
|
|
176
|
+
"$ref": "#/definitions/WorkerLogLevel"
|
|
177
|
+
},
|
|
178
|
+
"serviceName": {
|
|
179
|
+
"type": "string",
|
|
180
|
+
"description": "service to call"
|
|
181
|
+
},
|
|
182
|
+
"method": {
|
|
183
|
+
"type": "string",
|
|
184
|
+
"description": "method to call"
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
"required": [
|
|
188
|
+
"job",
|
|
189
|
+
"logLevel",
|
|
190
|
+
"logs",
|
|
191
|
+
"results",
|
|
192
|
+
"status",
|
|
193
|
+
"statusDetails",
|
|
194
|
+
"type",
|
|
195
|
+
"uuid"
|
|
196
|
+
],
|
|
197
|
+
"description": "Define a Webda Async Action",
|
|
198
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
199
|
+
"definitions": {
|
|
200
|
+
"WorkerLogLevel": {
|
|
201
|
+
"type": "string",
|
|
202
|
+
"enum": [
|
|
203
|
+
"ERROR",
|
|
204
|
+
"WARN",
|
|
205
|
+
"INFO",
|
|
206
|
+
"DEBUG",
|
|
207
|
+
"TRACE"
|
|
208
|
+
],
|
|
209
|
+
"description": "LogLevel as intersection to compare with integer values"
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
"title": "AsyncWebdaAction"
|
|
213
|
+
},
|
|
214
|
+
"webda/asyncoperationaction": {
|
|
215
|
+
"type": "object",
|
|
216
|
+
"properties": {
|
|
217
|
+
"_creationDate": {
|
|
218
|
+
"type": "string",
|
|
219
|
+
"format": "date-time",
|
|
220
|
+
"description": "Creation date",
|
|
221
|
+
"readOnly": true
|
|
222
|
+
},
|
|
223
|
+
"_lastUpdate": {
|
|
224
|
+
"type": "string",
|
|
225
|
+
"format": "date-time",
|
|
226
|
+
"description": "Last update date",
|
|
227
|
+
"readOnly": true
|
|
228
|
+
},
|
|
229
|
+
"uuid": {
|
|
230
|
+
"type": "string",
|
|
231
|
+
"description": "Action uuid"
|
|
232
|
+
},
|
|
233
|
+
"status": {
|
|
234
|
+
"type": "string",
|
|
235
|
+
"enum": [
|
|
236
|
+
"RUNNING",
|
|
237
|
+
"SUCCESS",
|
|
238
|
+
"ERROR",
|
|
239
|
+
"QUEUED",
|
|
240
|
+
"STARTING",
|
|
241
|
+
"TIMEOUT",
|
|
242
|
+
"SCHEDULED"
|
|
243
|
+
],
|
|
244
|
+
"description": "Current status"
|
|
245
|
+
},
|
|
246
|
+
"scheduled": {
|
|
247
|
+
"type": "number",
|
|
248
|
+
"description": "Timestamp when the action was scheduled"
|
|
249
|
+
},
|
|
250
|
+
"errorMessage": {
|
|
251
|
+
"type": "string",
|
|
252
|
+
"description": "If an error occured it should contain the message"
|
|
253
|
+
},
|
|
254
|
+
"job": {
|
|
255
|
+
"type": "object",
|
|
256
|
+
"description": "Job information"
|
|
257
|
+
},
|
|
258
|
+
"_lastJobUpdate": {
|
|
259
|
+
"type": "number",
|
|
260
|
+
"description": "Last time the job was updated",
|
|
261
|
+
"readOnly": true
|
|
262
|
+
},
|
|
263
|
+
"results": {
|
|
264
|
+
"description": "Results from the job"
|
|
265
|
+
},
|
|
266
|
+
"statusDetails": {
|
|
267
|
+
"description": "Job current status"
|
|
268
|
+
},
|
|
269
|
+
"type": {
|
|
270
|
+
"type": "string"
|
|
271
|
+
},
|
|
272
|
+
"arguments": {
|
|
273
|
+
"type": "array",
|
|
274
|
+
"items": {}
|
|
275
|
+
},
|
|
276
|
+
"logs": {
|
|
277
|
+
"type": "array",
|
|
278
|
+
"items": {
|
|
279
|
+
"type": "string"
|
|
280
|
+
},
|
|
281
|
+
"description": "Current logs"
|
|
282
|
+
},
|
|
283
|
+
"action": {
|
|
284
|
+
"type": "string",
|
|
285
|
+
"description": "Expected action for the job\n\nIt should be a verb"
|
|
286
|
+
},
|
|
287
|
+
"operationId": {
|
|
288
|
+
"type": "string"
|
|
289
|
+
},
|
|
290
|
+
"context": {
|
|
291
|
+
"type": "object",
|
|
292
|
+
"properties": {
|
|
293
|
+
"_promises": {
|
|
294
|
+
"type": "array",
|
|
295
|
+
"items": {},
|
|
296
|
+
"description": "Contain all registered promises to this context",
|
|
297
|
+
"readOnly": true
|
|
298
|
+
},
|
|
299
|
+
"_stream": {
|
|
300
|
+
"type": "object",
|
|
301
|
+
"properties": {
|
|
302
|
+
"writable": {
|
|
303
|
+
"type": "boolean"
|
|
304
|
+
},
|
|
305
|
+
"writableEnded": {
|
|
306
|
+
"type": "boolean"
|
|
307
|
+
},
|
|
308
|
+
"writableFinished": {
|
|
309
|
+
"type": "boolean"
|
|
310
|
+
},
|
|
311
|
+
"writableHighWaterMark": {
|
|
312
|
+
"type": "number"
|
|
313
|
+
},
|
|
314
|
+
"writableLength": {
|
|
315
|
+
"type": "number"
|
|
316
|
+
},
|
|
317
|
+
"writableObjectMode": {
|
|
318
|
+
"type": "boolean"
|
|
319
|
+
},
|
|
320
|
+
"writableCorked": {
|
|
321
|
+
"type": "number"
|
|
322
|
+
},
|
|
323
|
+
"destroyed": {
|
|
324
|
+
"type": "boolean"
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
"required": [
|
|
328
|
+
"destroyed",
|
|
329
|
+
"writable",
|
|
330
|
+
"writableCorked",
|
|
331
|
+
"writableEnded",
|
|
332
|
+
"writableFinished",
|
|
333
|
+
"writableHighWaterMark",
|
|
334
|
+
"writableLength",
|
|
335
|
+
"writableObjectMode"
|
|
336
|
+
],
|
|
337
|
+
"description": "Output stream",
|
|
338
|
+
"readOnly": true
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
"description": "OperationContext is used when call to an operation"
|
|
342
|
+
},
|
|
343
|
+
"logLevel": {
|
|
344
|
+
"$ref": "#/definitions/WorkerLogLevel"
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
"required": [
|
|
348
|
+
"context",
|
|
349
|
+
"job",
|
|
350
|
+
"logLevel",
|
|
351
|
+
"logs",
|
|
352
|
+
"operationId",
|
|
353
|
+
"results",
|
|
354
|
+
"status",
|
|
355
|
+
"statusDetails",
|
|
356
|
+
"type",
|
|
357
|
+
"uuid"
|
|
358
|
+
],
|
|
359
|
+
"description": "Operation called asynchronously",
|
|
360
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
361
|
+
"definitions": {
|
|
362
|
+
"WorkerLogLevel": {
|
|
363
|
+
"type": "string",
|
|
364
|
+
"enum": [
|
|
365
|
+
"ERROR",
|
|
366
|
+
"WARN",
|
|
367
|
+
"INFO",
|
|
368
|
+
"DEBUG",
|
|
369
|
+
"TRACE"
|
|
370
|
+
],
|
|
371
|
+
"description": "LogLevel as intersection to compare with integer values"
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
"title": "AsyncOperationAction"
|
|
375
|
+
},
|
|
94
376
|
"webda/asyncjobservice": {
|
|
95
377
|
"type": "object",
|
|
96
378
|
"properties": {
|
|
@@ -138,6 +420,26 @@
|
|
|
138
420
|
"type": "number",
|
|
139
421
|
"description": "Limit the maximum number of jobs running in //"
|
|
140
422
|
},
|
|
423
|
+
"onlyHttpHook": {
|
|
424
|
+
"type": "boolean",
|
|
425
|
+
"description": "Define if we should only use an http hook and not rely on store for AsyncOperation",
|
|
426
|
+
"default": false
|
|
427
|
+
},
|
|
428
|
+
"includeCron": {
|
|
429
|
+
"type": "boolean",
|
|
430
|
+
"description": "Include Cron annotation to launch them as AsyncOperationAction",
|
|
431
|
+
"default": true
|
|
432
|
+
},
|
|
433
|
+
"schedulerResolution": {
|
|
434
|
+
"type": "number",
|
|
435
|
+
"description": "Schedule action resolution\n\nIf set to 1000ms, you can schedule action per second by default it resolve per minute",
|
|
436
|
+
"default": 60000
|
|
437
|
+
},
|
|
438
|
+
"logsLimit": {
|
|
439
|
+
"type": "number",
|
|
440
|
+
"description": "Limit the number of lines of logs available for an async action\n\nIf you need to store large amount of logs then you should use the CloudWatchLogger or similar logger",
|
|
441
|
+
"default": 500
|
|
442
|
+
},
|
|
141
443
|
"openapi": {
|
|
142
444
|
"type": "object",
|
|
143
445
|
"additionalProperties": true
|
|
@@ -145,6 +447,7 @@
|
|
|
145
447
|
},
|
|
146
448
|
"required": [
|
|
147
449
|
"fallbackOnFirst",
|
|
450
|
+
"logsLimit",
|
|
148
451
|
"queue",
|
|
149
452
|
"runners",
|
|
150
453
|
"store",
|
|
@@ -310,6 +613,47 @@
|
|
|
310
613
|
}
|
|
311
614
|
},
|
|
312
615
|
"title": "LocalRunner"
|
|
616
|
+
},
|
|
617
|
+
"webda/servicerunner": {
|
|
618
|
+
"type": "object",
|
|
619
|
+
"properties": {
|
|
620
|
+
"type": {
|
|
621
|
+
"type": "string",
|
|
622
|
+
"description": "Type of the service"
|
|
623
|
+
},
|
|
624
|
+
"url": {
|
|
625
|
+
"type": "string",
|
|
626
|
+
"description": "URL on which to serve the content"
|
|
627
|
+
},
|
|
628
|
+
"actions": {
|
|
629
|
+
"type": "array",
|
|
630
|
+
"items": {
|
|
631
|
+
"type": "string"
|
|
632
|
+
},
|
|
633
|
+
"description": "Actions managed by the runner",
|
|
634
|
+
"default": []
|
|
635
|
+
},
|
|
636
|
+
"logFormat": {
|
|
637
|
+
"type": "string",
|
|
638
|
+
"description": "Define the log format",
|
|
639
|
+
"default": "ConsoleLoggerDefaultFormat"
|
|
640
|
+
},
|
|
641
|
+
"logSaveDelay": {
|
|
642
|
+
"type": "number",
|
|
643
|
+
"description": "How long before saving logs (in ms)",
|
|
644
|
+
"default": 5000
|
|
645
|
+
},
|
|
646
|
+
"openapi": {
|
|
647
|
+
"type": "object",
|
|
648
|
+
"additionalProperties": true
|
|
649
|
+
}
|
|
650
|
+
},
|
|
651
|
+
"required": [
|
|
652
|
+
"type"
|
|
653
|
+
],
|
|
654
|
+
"description": "Add the log format to capture",
|
|
655
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
656
|
+
"title": "ServiceRunner"
|
|
313
657
|
}
|
|
314
658
|
}
|
|
315
659
|
}
|