@aloma.io/integration-sdk 3.7.23 → 3.7.25
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/build/builder/runtime-context.mjs +5 -1
- package/build/controller/index.d.mts +2 -0
- package/build/controller/index.mjs +6 -0
- package/build/internal/dispatcher/index.d.mts +1 -1
- package/build/internal/dispatcher/index.mjs +2 -2
- package/build/internal/index.mjs +3 -0
- package/package.json +1 -1
- package/src/builder/runtime-context.mts +8 -0
- package/src/controller/index.mts +8 -0
- package/src/internal/dispatcher/index.mts +2 -2
- package/src/internal/index.mts +3 -0
@@ -51,10 +51,13 @@ export default class RuntimeContext {
|
|
51
51
|
if (data.auth?.oauth) {
|
52
52
|
configuration.oauth(data.auth?.oauth);
|
53
53
|
}
|
54
|
-
|
54
|
+
let healthInterval;
|
55
|
+
configuration.main(async ({ newTask, updateTask, config, oauth, getClient, getBlob, getBlobContent, createBlob, healthCheck }) => {
|
55
56
|
try {
|
57
|
+
clearInterval(healthInterval);
|
56
58
|
await controller._doStop();
|
57
59
|
await controller._doStart(config, oauth, newTask, updateTask, getClient, getBlob, getBlobContent, createBlob);
|
60
|
+
healthInterval = setInterval(() => healthCheck(controller), 30000);
|
58
61
|
}
|
59
62
|
catch (e) {
|
60
63
|
console.log(e);
|
@@ -62,6 +65,7 @@ export default class RuntimeContext {
|
|
62
65
|
});
|
63
66
|
connector.run();
|
64
67
|
const term = async () => {
|
68
|
+
clearInterval(healthInterval);
|
65
69
|
await controller._doStop(true);
|
66
70
|
process.exit(0);
|
67
71
|
};
|
@@ -29,9 +29,11 @@ export declare abstract class AbstractController {
|
|
29
29
|
meta?: any;
|
30
30
|
}>;
|
31
31
|
protected getBlobContent(id: string): Promise<string>;
|
32
|
+
protected healthCheck(): Promise<any>;
|
32
33
|
__endpoint(arg: any): Promise<any | null>;
|
33
34
|
__configQuery(arg: any): Promise<any | null>;
|
34
35
|
__default(arg: any): Promise<any | null>;
|
36
|
+
__healthCheck(): Promise<any>;
|
35
37
|
_doStart(config: any, client: any, newTask: any, updateTask: any, getClient: any, getBlob: any, getBlobContent: any, createBlob: any): Promise<void>;
|
36
38
|
_doStop(isShutdown?: boolean): Promise<void>;
|
37
39
|
}
|
@@ -30,6 +30,9 @@ export class AbstractController {
|
|
30
30
|
async getBlobContent(id) {
|
31
31
|
throw new Error("not implemented");
|
32
32
|
}
|
33
|
+
async healthCheck() {
|
34
|
+
// blank, throw an error if unhealthy
|
35
|
+
}
|
33
36
|
async __endpoint(arg) {
|
34
37
|
return this.endpoint(arg);
|
35
38
|
}
|
@@ -39,6 +42,9 @@ export class AbstractController {
|
|
39
42
|
async __default(arg) {
|
40
43
|
return this.fallback(arg);
|
41
44
|
}
|
45
|
+
async __healthCheck() {
|
46
|
+
return this.healthCheck();
|
47
|
+
}
|
42
48
|
async _doStart(config, client, newTask, updateTask, getClient, getBlob, getBlobContent, createBlob) {
|
43
49
|
this.config = config;
|
44
50
|
this.client = client;
|
@@ -121,9 +121,9 @@ ${arg.configurableClientScope}
|
|
121
121
|
var local = this;
|
122
122
|
const _resolvers = { ...this._resolvers };
|
123
123
|
const main = this._main || (() => { });
|
124
|
-
const start = async (
|
124
|
+
const start = async (arg) => {
|
125
125
|
console.log("starting ...");
|
126
|
-
await main(
|
126
|
+
await main(arg);
|
127
127
|
};
|
128
128
|
const resolveMethod = (query) => {
|
129
129
|
let current = _resolvers;
|
package/build/internal/index.mjs
CHANGED
@@ -342,6 +342,9 @@ ${text}
|
|
342
342
|
getBlob,
|
343
343
|
getBlobContent,
|
344
344
|
createBlob,
|
345
|
+
healthCheck: async (controller) => {
|
346
|
+
console.log('health check', await controller.__healthCheck());
|
347
|
+
},
|
345
348
|
getClient: (arg) => theOAuth ? theOAuth.getClient(arg) : new Fetcher(arg),
|
346
349
|
newTask: (name, data) => {
|
347
350
|
return new Promise((resolve, reject) => {
|
package/package.json
CHANGED
@@ -65,6 +65,8 @@ export default class RuntimeContext {
|
|
65
65
|
configuration.oauth(data.auth?.oauth);
|
66
66
|
}
|
67
67
|
|
68
|
+
let healthInterval;
|
69
|
+
|
68
70
|
configuration.main(
|
69
71
|
async ({
|
70
72
|
newTask,
|
@@ -75,8 +77,11 @@ export default class RuntimeContext {
|
|
75
77
|
getBlob,
|
76
78
|
getBlobContent,
|
77
79
|
createBlob,
|
80
|
+
healthCheck
|
78
81
|
}) => {
|
79
82
|
try {
|
83
|
+
clearInterval(healthInterval);
|
84
|
+
|
80
85
|
await controller._doStop();
|
81
86
|
await controller._doStart(
|
82
87
|
config,
|
@@ -88,6 +93,8 @@ export default class RuntimeContext {
|
|
88
93
|
getBlobContent,
|
89
94
|
createBlob,
|
90
95
|
);
|
96
|
+
|
97
|
+
healthInterval = setInterval(() => healthCheck(controller), 30000);
|
91
98
|
} catch (e) {
|
92
99
|
console.log(e);
|
93
100
|
}
|
@@ -97,6 +104,7 @@ export default class RuntimeContext {
|
|
97
104
|
connector.run();
|
98
105
|
|
99
106
|
const term = async () => {
|
107
|
+
clearInterval(healthInterval);
|
100
108
|
await controller._doStop(true);
|
101
109
|
|
102
110
|
process.exit(0);
|
package/src/controller/index.mts
CHANGED
@@ -70,6 +70,10 @@ export abstract class AbstractController {
|
|
70
70
|
throw new Error("not implemented");
|
71
71
|
}
|
72
72
|
|
73
|
+
protected async healthCheck(): Promise<any> {
|
74
|
+
// blank, throw an error if unhealthy
|
75
|
+
}
|
76
|
+
|
73
77
|
async __endpoint(arg: any): Promise<any | null> {
|
74
78
|
return this.endpoint(arg);
|
75
79
|
}
|
@@ -82,6 +86,10 @@ export abstract class AbstractController {
|
|
82
86
|
return this.fallback(arg);
|
83
87
|
}
|
84
88
|
|
89
|
+
async __healthCheck(): Promise<any> {
|
90
|
+
return this.healthCheck();
|
91
|
+
}
|
92
|
+
|
85
93
|
async _doStart(
|
86
94
|
config: any,
|
87
95
|
client: any,
|
@@ -146,9 +146,9 @@ ${arg.configurableClientScope}
|
|
146
146
|
|
147
147
|
const main = this._main || (() => {});
|
148
148
|
|
149
|
-
const start = async (
|
149
|
+
const start = async (arg) => {
|
150
150
|
console.log("starting ...");
|
151
|
-
await main(
|
151
|
+
await main(arg);
|
152
152
|
};
|
153
153
|
|
154
154
|
const resolveMethod = (query) => {
|
package/src/internal/index.mts
CHANGED
@@ -432,6 +432,9 @@ ${text}
|
|
432
432
|
getBlob,
|
433
433
|
getBlobContent,
|
434
434
|
createBlob,
|
435
|
+
healthCheck: async (controller) => {
|
436
|
+
console.log('health check', await controller.__healthCheck());
|
437
|
+
},
|
435
438
|
getClient: (arg) =>
|
436
439
|
theOAuth ? theOAuth.getClient(arg) : new Fetcher(arg),
|
437
440
|
newTask: (name, data) => {
|