@kapeta/local-cluster-service 0.8.3 → 0.9.1

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.
Files changed (71) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/src/assetManager.js +7 -4
  3. package/dist/cjs/src/clusterService.js +2 -0
  4. package/dist/cjs/src/codeGeneratorManager.js +3 -3
  5. package/dist/cjs/src/config/routes.js +1 -1
  6. package/dist/cjs/src/configManager.js +13 -1
  7. package/dist/cjs/src/containerManager.d.ts +25 -2
  8. package/dist/cjs/src/containerManager.js +51 -16
  9. package/dist/cjs/src/definitionsManager.d.ts +11 -0
  10. package/dist/cjs/src/definitionsManager.js +44 -0
  11. package/dist/cjs/src/filesystemManager.js +0 -2
  12. package/dist/cjs/src/instanceManager.d.ts +23 -47
  13. package/dist/cjs/src/instanceManager.js +416 -235
  14. package/dist/cjs/src/instances/routes.js +23 -14
  15. package/dist/cjs/src/middleware/kapeta.js +7 -0
  16. package/dist/cjs/src/networkManager.js +6 -0
  17. package/dist/cjs/src/operatorManager.js +8 -4
  18. package/dist/cjs/src/providerManager.js +3 -3
  19. package/dist/cjs/src/repositoryManager.js +7 -3
  20. package/dist/cjs/src/serviceManager.js +5 -0
  21. package/dist/cjs/src/types.d.ts +39 -13
  22. package/dist/cjs/src/types.js +28 -0
  23. package/dist/cjs/src/utils/BlockInstanceRunner.d.ts +3 -3
  24. package/dist/cjs/src/utils/BlockInstanceRunner.js +34 -32
  25. package/dist/cjs/src/utils/utils.d.ts +2 -0
  26. package/dist/cjs/src/utils/utils.js +17 -1
  27. package/dist/esm/src/assetManager.js +7 -4
  28. package/dist/esm/src/clusterService.js +2 -0
  29. package/dist/esm/src/codeGeneratorManager.js +3 -3
  30. package/dist/esm/src/config/routes.js +1 -1
  31. package/dist/esm/src/configManager.js +13 -1
  32. package/dist/esm/src/containerManager.d.ts +25 -2
  33. package/dist/esm/src/containerManager.js +50 -15
  34. package/dist/esm/src/definitionsManager.d.ts +11 -0
  35. package/dist/esm/src/definitionsManager.js +38 -0
  36. package/dist/esm/src/filesystemManager.js +0 -2
  37. package/dist/esm/src/instanceManager.d.ts +23 -47
  38. package/dist/esm/src/instanceManager.js +416 -236
  39. package/dist/esm/src/instances/routes.js +23 -14
  40. package/dist/esm/src/middleware/kapeta.js +7 -0
  41. package/dist/esm/src/networkManager.js +6 -0
  42. package/dist/esm/src/operatorManager.js +8 -4
  43. package/dist/esm/src/providerManager.js +3 -3
  44. package/dist/esm/src/repositoryManager.js +7 -3
  45. package/dist/esm/src/serviceManager.js +5 -0
  46. package/dist/esm/src/types.d.ts +39 -13
  47. package/dist/esm/src/types.js +27 -1
  48. package/dist/esm/src/utils/BlockInstanceRunner.d.ts +3 -3
  49. package/dist/esm/src/utils/BlockInstanceRunner.js +35 -33
  50. package/dist/esm/src/utils/utils.d.ts +2 -0
  51. package/dist/esm/src/utils/utils.js +14 -0
  52. package/package.json +2 -1
  53. package/src/assetManager.ts +7 -4
  54. package/src/clusterService.ts +3 -0
  55. package/src/codeGeneratorManager.ts +3 -2
  56. package/src/config/routes.ts +1 -1
  57. package/src/configManager.ts +13 -1
  58. package/src/containerManager.ts +72 -16
  59. package/src/definitionsManager.ts +54 -0
  60. package/src/filesystemManager.ts +0 -2
  61. package/src/instanceManager.ts +495 -266
  62. package/src/instances/routes.ts +23 -17
  63. package/src/middleware/kapeta.ts +10 -0
  64. package/src/networkManager.ts +6 -0
  65. package/src/operatorManager.ts +11 -6
  66. package/src/providerManager.ts +3 -2
  67. package/src/repositoryManager.ts +7 -3
  68. package/src/serviceManager.ts +6 -0
  69. package/src/types.ts +44 -14
  70. package/src/utils/BlockInstanceRunner.ts +39 -36
  71. package/src/utils/utils.ts +18 -0
@@ -3,12 +3,13 @@ import FS from 'node:fs';
3
3
  import FSExtra from 'fs-extra';
4
4
  import YAML from 'yaml';
5
5
  import NodeCache from 'node-cache';
6
- import ClusterConfiguration from '@kapeta/local-cluster-config';
7
6
  import { codeGeneratorManager } from './codeGeneratorManager';
8
7
  import { progressListener } from './progressListener';
9
8
  import { parseKapetaUri } from '@kapeta/nodejs-utils';
10
9
  import { repositoryManager } from './repositoryManager';
11
10
  import { Actions } from '@kapeta/nodejs-registry-utils';
11
+ import { definitionsManager } from './definitionsManager';
12
+ import { normalizeKapetaUri } from './utils/utils';
12
13
  function enrichAsset(asset) {
13
14
  return {
14
15
  ref: `kapeta://${asset.definition.metadata.name}:${asset.version}`,
@@ -47,7 +48,7 @@ class AssetManager {
47
48
  */
48
49
  getAssets(assetKinds) {
49
50
  if (!assetKinds) {
50
- const blockTypeProviders = ClusterConfiguration.getDefinitions([
51
+ const blockTypeProviders = definitionsManager.getDefinitions([
51
52
  'core/block-type',
52
53
  'core/block-type-operator',
53
54
  ]);
@@ -56,7 +57,7 @@ class AssetManager {
56
57
  });
57
58
  assetKinds.push('core/plan');
58
59
  }
59
- const assets = ClusterConfiguration.getDefinitions(assetKinds);
60
+ const assets = definitionsManager.getDefinitions(assetKinds);
60
61
  return assets.map(enrichAsset);
61
62
  }
62
63
  getPlans() {
@@ -70,13 +71,15 @@ class AssetManager {
70
71
  return asset.data;
71
72
  }
72
73
  async getAsset(ref, noCache = false) {
74
+ ref = normalizeKapetaUri(ref);
73
75
  const cacheKey = `getAsset:${ref}`;
74
76
  if (!noCache && this.cache.has(cacheKey)) {
75
77
  return this.cache.get(cacheKey);
76
78
  }
77
79
  const uri = parseKapetaUri(ref);
78
80
  await repositoryManager.ensureAsset(uri.handle, uri.name, uri.version);
79
- let asset = ClusterConfiguration.getDefinitions()
81
+ let asset = definitionsManager
82
+ .getDefinitions()
80
83
  .map(enrichAsset)
81
84
  .find((a) => parseKapetaUri(a.ref).equals(uri));
82
85
  if (!asset) {
@@ -1,3 +1,4 @@
1
+ import { normalizeKapetaUri } from './utils/utils';
1
2
  const net = require('net');
2
3
  const DEFAULT_SERVER_PORT = 35100;
3
4
  const DEFAULT_START_PORT = 40000;
@@ -105,6 +106,7 @@ class ClusterService {
105
106
  * @return {string}
106
107
  */
107
108
  getProxyPath(systemId, consumerInstanceId, consumerResourceName, portType) {
109
+ systemId = normalizeKapetaUri(systemId);
108
110
  return `/proxy/${encodeURIComponent(systemId)}/${encodeURIComponent(consumerInstanceId)}/${encodeURIComponent(consumerResourceName)}/${encodeURIComponent(portType)}/`;
109
111
  }
110
112
  }
@@ -1,12 +1,12 @@
1
1
  import Path from 'path';
2
2
  import { registry as Targets, BlockCodeGenerator, CodeWriter } from '@kapeta/codegen';
3
- import ClusterConfiguration from '@kapeta/local-cluster-config';
3
+ import { definitionsManager } from './definitionsManager';
4
4
  const TARGET_KIND = 'core/language-target';
5
5
  const BLOCK_TYPE_KIND = 'core/block-type';
6
6
  class CodeGeneratorManager {
7
7
  async reload() {
8
8
  Targets.reset();
9
- const languageTargets = ClusterConfiguration.getDefinitions(TARGET_KIND);
9
+ const languageTargets = definitionsManager.getDefinitions(TARGET_KIND);
10
10
  for (const languageTarget of languageTargets) {
11
11
  const key = `${languageTarget.definition.metadata.name}:${languageTarget.version}`;
12
12
  try {
@@ -28,7 +28,7 @@ class CodeGeneratorManager {
28
28
  //Not all block types have targets
29
29
  return false;
30
30
  }
31
- const blockTypes = ClusterConfiguration.getDefinitions(BLOCK_TYPE_KIND);
31
+ const blockTypes = definitionsManager.getDefinitions(BLOCK_TYPE_KIND);
32
32
  const blockTypeKinds = blockTypes.map((blockType) => blockType.definition.metadata.name.toLowerCase() + ':' + blockType.version);
33
33
  return !!(yamlContent && yamlContent.kind && blockTypeKinds.indexOf(yamlContent.kind.toLowerCase()) > -1);
34
34
  }
@@ -32,7 +32,7 @@ router.put('/instance', async (req, res) => {
32
32
  if (req.kapeta.instanceId) {
33
33
  configManager.setConfigForSection(req.kapeta.systemId, req.kapeta.instanceId, config);
34
34
  //Restart the instance if it is running after config change
35
- await instanceManager.restartIfRunning(req.kapeta.systemId, req.kapeta.instanceId);
35
+ await instanceManager.restart(req.kapeta.systemId, req.kapeta.instanceId);
36
36
  }
37
37
  else {
38
38
  configManager.setConfigForSystem(req.kapeta.systemId, config);
@@ -1,30 +1,36 @@
1
1
  import { storageService } from './storageService';
2
2
  import { assetManager } from './assetManager';
3
3
  import { parseKapetaUri } from '@kapeta/nodejs-utils';
4
+ import { normalizeKapetaUri } from './utils/utils';
4
5
  class ConfigManager {
5
6
  _config;
6
7
  constructor() {
7
8
  this._config = storageService.section('config');
8
9
  }
9
10
  _forSystem(systemId) {
11
+ systemId = normalizeKapetaUri(systemId);
10
12
  if (!this._config[systemId]) {
11
13
  this._config[systemId] = {};
12
14
  }
13
15
  return this._config[systemId];
14
16
  }
15
17
  setConfigForSystem(systemId, config) {
18
+ systemId = normalizeKapetaUri(systemId);
16
19
  const systemConfig = config || {};
17
20
  storageService.put('config', systemId, systemConfig);
18
21
  }
19
22
  getConfigForSystem(systemId) {
23
+ systemId = normalizeKapetaUri(systemId);
20
24
  return this._forSystem(systemId);
21
25
  }
22
26
  setConfigForSection(systemId, sectionId, config) {
27
+ systemId = normalizeKapetaUri(systemId);
23
28
  let systemConfig = this._forSystem(systemId);
24
29
  systemConfig[sectionId] = config || {};
25
30
  storageService.put('config', systemId, systemConfig);
26
31
  }
27
32
  getConfigForSection(systemId, sectionId) {
33
+ systemId = normalizeKapetaUri(systemId);
28
34
  const systemConfig = this._forSystem(systemId);
29
35
  if (!systemConfig[sectionId]) {
30
36
  systemConfig[sectionId] = {};
@@ -48,6 +54,10 @@ class ConfigManager {
48
54
  * @returns {Promise<{systemId:string,instanceId:string}>}
49
55
  */
50
56
  async resolveIdentity(blockRef, systemId) {
57
+ blockRef = normalizeKapetaUri(blockRef);
58
+ if (systemId) {
59
+ systemId = normalizeKapetaUri(systemId);
60
+ }
51
61
  const planAssets = assetManager.getPlans();
52
62
  const blockUri = parseKapetaUri(blockRef);
53
63
  let matchingIdentities = [];
@@ -63,7 +73,7 @@ class ConfigManager {
63
73
  const refUri = parseKapetaUri(blockInstance.block.ref);
64
74
  if (refUri.equals(blockUri)) {
65
75
  matchingIdentities.push({
66
- systemId: planAsset.ref,
76
+ systemId: normalizeKapetaUri(planAsset.ref),
67
77
  instanceId: blockInstance.id,
68
78
  });
69
79
  }
@@ -84,6 +94,8 @@ class ConfigManager {
84
94
  return matchingIdentities[0];
85
95
  }
86
96
  async verifyIdentity(blockRef, systemId, instanceId) {
97
+ blockRef = normalizeKapetaUri(blockRef);
98
+ systemId = normalizeKapetaUri(systemId);
87
99
  const planAssets = assetManager.getPlans();
88
100
  const systemUri = systemId ? parseKapetaUri(systemId) : null;
89
101
  const blockUri = parseKapetaUri(blockRef);
@@ -17,12 +17,31 @@ export interface DockerMounts {
17
17
  ReadOnly: boolean;
18
18
  Consistency: string;
19
19
  }
20
+ interface DockerState {
21
+ Status: 'created' | 'running' | 'paused' | 'restarting' | 'removing' | 'exited' | 'dead';
22
+ Running: boolean;
23
+ Paused: boolean;
24
+ Restarting: boolean;
25
+ OOMKilled: boolean;
26
+ Dead: boolean;
27
+ Pid: number;
28
+ ExitCode: number;
29
+ Error: string;
30
+ StartedAt: string;
31
+ FinishedAt: string;
32
+ Health?: {
33
+ Status: 'starting' | 'healthy' | 'unhealthy' | 'none';
34
+ FailingStreak: number;
35
+ Log: any[] | null;
36
+ };
37
+ }
20
38
  interface Health {
21
39
  cmd: string;
22
40
  interval?: number;
23
41
  timeout?: number;
24
42
  retries?: number;
25
43
  }
44
+ export declare const HEALTH_CHECK_TIMEOUT: number;
26
45
  declare class ContainerManager {
27
46
  private _docker;
28
47
  private _alive;
@@ -36,7 +55,7 @@ declare class ContainerManager {
36
55
  createMounts(kind: string, mountOpts: StringMap): StringMap;
37
56
  ping(): Promise<void>;
38
57
  docker(): Docker;
39
- getContainerByName(containerName: string): Promise<Container | undefined>;
58
+ getContainerByName(containerName: string): Promise<ContainerInfo | undefined>;
40
59
  pull(image: string, cacheForMS?: number): Promise<void>;
41
60
  toDockerMounts(mounts: StringMap): DockerMounts[];
42
61
  toDockerHealth(health: Health): {
@@ -57,6 +76,9 @@ declare class ContainerManager {
57
76
  waitForHealthy(container: Container, attempt?: number): Promise<void>;
58
77
  _isReady(container: Container): Promise<any>;
59
78
  _isHealthy(container: Container): Promise<boolean>;
79
+ remove(container: Container, opts?: {
80
+ force?: boolean;
81
+ }): Promise<void>;
60
82
  /**
61
83
  *
62
84
  * @param name
@@ -84,7 +106,8 @@ export declare class ContainerInfo {
84
106
  protocol: string;
85
107
  hostPort: string;
86
108
  } | null>;
87
- getStatus(): Promise<any>;
109
+ inspect(): Promise<any>;
110
+ status(): Promise<DockerState>;
88
111
  getPorts(): Promise<PortMap | false>;
89
112
  }
90
113
  export declare function getExtraHosts(dockerVersion: string): string[] | undefined;
@@ -7,12 +7,14 @@ import { Docker } from 'node-docker-api';
7
7
  import { parseKapetaUri } from '@kapeta/nodejs-utils';
8
8
  import ClusterConfiguration from '@kapeta/local-cluster-config';
9
9
  import { getBindHost } from './utils/utils';
10
+ import uuid from "node-uuid";
10
11
  const LABEL_PORT_PREFIX = 'kapeta_port-';
11
12
  const NANO_SECOND = 1000000;
12
- const HEALTH_CHECK_INTERVAL = 2000;
13
- const HEALTH_CHECK_MAX = 30;
13
+ const HEALTH_CHECK_INTERVAL = 3000;
14
+ const HEALTH_CHECK_MAX = 20;
14
15
  const IMAGE_PULL_CACHE_TTL = 30 * 60 * 1000;
15
16
  const IMAGE_PULL_CACHE = {};
17
+ export const HEALTH_CHECK_TIMEOUT = HEALTH_CHECK_INTERVAL * HEALTH_CHECK_MAX * 2;
16
18
  const promisifyStream = (stream) => new Promise((resolve, reject) => {
17
19
  stream.on('data', (d) => console.log(d.toString()));
18
20
  stream.on('end', resolve);
@@ -125,9 +127,14 @@ class ContainerManager {
125
127
  }
126
128
  async getContainerByName(containerName) {
127
129
  const containers = await this.docker().container.list({ all: true });
128
- return containers.find((container) => {
129
- return container.data.Names.indexOf(`/${containerName}`) > -1;
130
+ const out = containers.find((container) => {
131
+ const containerData = container.data;
132
+ return containerData.Names.indexOf(`/${containerName}`) > -1;
130
133
  });
134
+ if (out) {
135
+ return new ContainerInfo(out);
136
+ }
137
+ return undefined;
131
138
  }
132
139
  async pull(image, cacheForMS = IMAGE_PULL_CACHE_TTL) {
133
140
  let [imageName, tag] = image.split(/:/);
@@ -288,17 +295,36 @@ class ContainerManager {
288
295
  });
289
296
  }
290
297
  async _isReady(container) {
291
- const info = await container.status();
298
+ let info;
299
+ try {
300
+ info = await container.status();
301
+ }
302
+ catch (err) {
303
+ return false;
304
+ }
292
305
  const infoData = info?.data;
293
- if (infoData?.State?.Status === 'exited') {
306
+ const state = infoData?.State;
307
+ if (state?.Status === 'exited' || state?.Status === 'removing' || state?.Status === 'dead') {
294
308
  throw new Error('Container exited unexpectedly');
295
309
  }
296
310
  return infoData?.State?.Running ?? false;
297
311
  }
298
312
  async _isHealthy(container) {
299
- const info = await container.status();
300
- const infoData = info?.data;
301
- return infoData?.State?.Health?.Status === 'healthy';
313
+ try {
314
+ const info = await container.status();
315
+ const infoData = info?.data;
316
+ return infoData?.State?.Health?.Status === 'healthy';
317
+ }
318
+ catch (err) {
319
+ return false;
320
+ }
321
+ }
322
+ async remove(container, opts) {
323
+ const newName = 'deleting-' + uuid.v4();
324
+ const containerData = container.data;
325
+ // Rename the container first to avoid name conflicts if people start the same container
326
+ await container.rename({ name: newName });
327
+ await container.delete({ force: !!opts?.force });
302
328
  }
303
329
  /**
304
330
  *
@@ -339,7 +365,7 @@ export class ContainerInfo {
339
365
  return this._container;
340
366
  }
341
367
  async isRunning() {
342
- const inspectResult = await this.getStatus();
368
+ const inspectResult = await this.inspect();
343
369
  if (!inspectResult || !inspectResult.State) {
344
370
  return false;
345
371
  }
@@ -355,7 +381,7 @@ export class ContainerInfo {
355
381
  await this._container.stop();
356
382
  }
357
383
  async remove(opts) {
358
- await this._container.delete({ force: !!opts?.force });
384
+ await containerManager.remove(this._container, opts);
359
385
  }
360
386
  async getPort(type) {
361
387
  const ports = await this.getPorts();
@@ -364,12 +390,21 @@ export class ContainerInfo {
364
390
  }
365
391
  return null;
366
392
  }
367
- async getStatus() {
368
- const result = await this._container.status();
369
- return result ? result.data : null;
393
+ async inspect() {
394
+ try {
395
+ const result = await this._container.status();
396
+ return result ? result.data : null;
397
+ }
398
+ catch (err) {
399
+ return null;
400
+ }
401
+ }
402
+ async status() {
403
+ const result = await this.inspect();
404
+ return result.State;
370
405
  }
371
406
  async getPorts() {
372
- const inspectResult = await this.getStatus();
407
+ const inspectResult = await this.inspect();
373
408
  if (!inspectResult || !inspectResult.Config || !inspectResult.Config.Labels) {
374
409
  return false;
375
410
  }
@@ -0,0 +1,11 @@
1
+ import { DefinitionInfo } from '@kapeta/local-cluster-config';
2
+ declare class DefinitionsManager {
3
+ private cache;
4
+ private getKey;
5
+ clearCache(): void;
6
+ private doCached;
7
+ getDefinitions(kindFilter?: string | string[]): DefinitionInfo[];
8
+ getProviderDefinitions(): DefinitionInfo[];
9
+ }
10
+ export declare const definitionsManager: DefinitionsManager;
11
+ export {};
@@ -0,0 +1,38 @@
1
+ import ClusterConfiguration from '@kapeta/local-cluster-config';
2
+ const CACHE_TTL = 60 * 1000; // 1 min
3
+ class DefinitionsManager {
4
+ cache = {};
5
+ getKey(kindFilter) {
6
+ if (kindFilter) {
7
+ if (Array.isArray(kindFilter)) {
8
+ return kindFilter.join(',');
9
+ }
10
+ return kindFilter;
11
+ }
12
+ return 'none';
13
+ }
14
+ clearCache() {
15
+ this.cache = {};
16
+ }
17
+ doCached(key, getter) {
18
+ if (this.cache[key]) {
19
+ if (this.cache[key].expires > Date.now()) {
20
+ return this.cache[key].definitions;
21
+ }
22
+ delete this.cache[key];
23
+ }
24
+ this.cache[key] = {
25
+ expires: Date.now() + CACHE_TTL,
26
+ definitions: getter(),
27
+ };
28
+ return this.cache[key].definitions;
29
+ }
30
+ getDefinitions(kindFilter) {
31
+ const key = this.getKey(kindFilter);
32
+ return this.doCached(key, () => ClusterConfiguration.getDefinitions(kindFilter));
33
+ }
34
+ getProviderDefinitions() {
35
+ return this.doCached('providers', () => ClusterConfiguration.getProviderDefinitions());
36
+ }
37
+ }
38
+ export const definitionsManager = new DefinitionsManager();
@@ -15,9 +15,7 @@ function isFile(path) {
15
15
  class FilesystemManager {
16
16
  async writeFile(path, data) {
17
17
  const dirName = Path.dirname(path);
18
- console.log('Dir name', dirName, path);
19
18
  if (!FS.existsSync(dirName)) {
20
- console.log('Making folder', dirName);
21
19
  FSExtra.mkdirpSync(dirName, {});
22
20
  }
23
21
  FS.writeFileSync(path, data);
@@ -1,56 +1,32 @@
1
- import { InstanceInfo, ProcessInfo } from './types';
2
- declare class InstanceManager {
1
+ import { InstanceInfo } from './types';
2
+ export declare class InstanceManager {
3
3
  private _interval;
4
- /**
5
- * Contains an array of running instances that have self-registered with this
6
- * cluster service. This is done by the Kapeta SDKs
7
- */
8
- private _instances;
9
- /**
10
- * Contains the process info for the instances started by this manager. In memory only
11
- * so can't be relied on for knowing everything that's running.
12
- *
13
- */
14
- private _processes;
4
+ private readonly _instances;
15
5
  constructor();
16
- _save(): void;
17
- _checkInstances(): Promise<void>;
18
- _isRunning(instance: InstanceInfo): Promise<any>;
19
- _getInstanceStatus(instance: InstanceInfo): Promise<string>;
6
+ private checkInstancesLater;
20
7
  getInstances(): InstanceInfo[];
21
8
  getInstancesForPlan(systemId: string): InstanceInfo[];
22
- /**
23
- * Get instance information
24
- *
25
- * @param {string} systemId
26
- * @param {string} instanceId
27
- * @return {*}
28
- */
29
9
  getInstance(systemId: string, instanceId: string): InstanceInfo | undefined;
10
+ saveInternalInstance(instance: InstanceInfo): Promise<InstanceInfo>;
30
11
  /**
31
- *
32
- * @param {string} systemId
33
- * @param {string} instanceId
34
- * @param {InstanceInfo} info
35
- * @return {Promise<void>}
36
- */
37
- registerInstance(systemId: string, instanceId: string, info: Omit<InstanceInfo, 'systemId' | 'instanceId'>): Promise<void>;
38
- setInstanceAsStopped(systemId: string, instanceId: string): void;
39
- _emit(systemId: string, type: string, payload: any): void;
40
- createProcessesForPlan(planRef: string): Promise<ProcessInfo[]>;
41
- _stopInstance(instance: InstanceInfo): Promise<void>;
42
- stopAllForPlan(planRef: string): Promise<void>;
43
- createProcess(planRef: string, instanceId: string): Promise<ProcessInfo>;
44
- /**
45
- *
46
- * @param {string} planRef
47
- * @param {string} instanceId
48
- * @return {ProcessInfo|null}
12
+ * Method is called when instance is started from the Kapeta SDKs (e.g. NodeJS SDK)
13
+ * which self-registers with the cluster service locally on startup.
49
14
  */
50
- getProcessForInstance(planRef: string, instanceId: string): ProcessInfo | null;
51
- restartIfRunning(planRef: string, instanceId: string): Promise<ProcessInfo | undefined>;
52
- stopProcess(planRef: string, instanceId: string): Promise<void>;
53
- stopAllProcesses(): Promise<void>;
15
+ registerInstanceFromSDK(systemId: string, instanceId: string, info: Omit<InstanceInfo, 'systemId' | 'instanceId'>): Promise<InstanceInfo | undefined>;
16
+ private getHealthUrl;
17
+ markAsStopped(systemId: string, instanceId: string): void;
18
+ startAllForPlan(systemId: string): Promise<InstanceInfo[]>;
19
+ stop(systemId: string, instanceId: string): Promise<void>;
20
+ stopAllForPlan(systemId: string): Promise<void>;
21
+ start(systemId: string, instanceId: string): Promise<InstanceInfo>;
22
+ restart(systemId: string, instanceId: string): Promise<InstanceInfo>;
23
+ stopAll(): Promise<void>;
24
+ private stopInstances;
25
+ private save;
26
+ private checkInstances;
27
+ private getExternalStatus;
28
+ private requestInstanceStatus;
29
+ private emitSystemEvent;
30
+ private emitInstanceEvent;
54
31
  }
55
32
  export declare const instanceManager: InstanceManager;
56
- export {};