@aloma.io/integration-sdk 3.7.24 → 3.7.26

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.
@@ -51,10 +51,15 @@ export default class RuntimeContext {
51
51
  if (data.auth?.oauth) {
52
52
  configuration.oauth(data.auth?.oauth);
53
53
  }
54
- configuration.main(async ({ newTask, updateTask, config, oauth, getClient, getBlob, getBlobContent, createBlob, }) => {
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
+ // TODO remove
61
+ console.log('scheduling health check');
62
+ healthInterval = setInterval(() => healthCheck(controller), 30000);
58
63
  }
59
64
  catch (e) {
60
65
  console.log(e);
@@ -62,6 +67,7 @@ export default class RuntimeContext {
62
67
  });
63
68
  connector.run();
64
69
  const term = async () => {
70
+ clearInterval(healthInterval);
65
71
  await controller._doStop(true);
66
72
  process.exit(0);
67
73
  };
@@ -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;
@@ -21,7 +21,7 @@ export default class Dispatcher {
21
21
  variables: any;
22
22
  }) => Promise<any>;
23
23
  processPacket: (packet: any) => Promise<any>;
24
- start: (transport: any) => Promise<void>;
24
+ start: (arg: any) => Promise<void>;
25
25
  };
26
26
  onConfig(arg0: any): void;
27
27
  }
@@ -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 (transport) => {
124
+ const start = async (arg) => {
125
125
  console.log("starting ...");
126
- await main(transport);
126
+ await main(arg);
127
127
  };
128
128
  const resolveMethod = (query) => {
129
129
  let current = _resolvers;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.7.24",
3
+ "version": "3.7.26",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -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,10 @@ export default class RuntimeContext {
88
93
  getBlobContent,
89
94
  createBlob,
90
95
  );
96
+
97
+ // TODO remove
98
+ console.log('scheduling health check')
99
+ healthInterval = setInterval(() => healthCheck(controller), 30000);
91
100
  } catch (e) {
92
101
  console.log(e);
93
102
  }
@@ -97,6 +106,7 @@ export default class RuntimeContext {
97
106
  connector.run();
98
107
 
99
108
  const term = async () => {
109
+ clearInterval(healthInterval);
100
110
  await controller._doStop(true);
101
111
 
102
112
  process.exit(0);
@@ -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 (transport) => {
149
+ const start = async (arg) => {
150
150
  console.log("starting ...");
151
- await main(transport);
151
+ await main(arg);
152
152
  };
153
153
 
154
154
  const resolveMethod = (query) => {
@@ -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) => {