@kapeta/local-cluster-service 0.19.2 → 0.19.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.19.3](https://github.com/kapetacom/local-cluster-service/compare/v0.19.2...v0.19.3) (2023-09-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * if codegen is already started for block - run after ([#69](https://github.com/kapetacom/local-cluster-service/issues/69)) ([a1b13ee](https://github.com/kapetacom/local-cluster-service/commit/a1b13eeab8413be8c165419ee36c26e3509338b4))
7
+
1
8
  ## [0.19.2](https://github.com/kapetacom/local-cluster-service/compare/v0.19.1...v0.19.2) (2023-09-05)
2
9
 
3
10
 
@@ -16,6 +16,7 @@ const definitionsManager_1 = require("./definitionsManager");
16
16
  const utils_1 = require("./utils/utils");
17
17
  const taskManager_1 = require("./taskManager");
18
18
  const cacheManager_1 = require("./cacheManager");
19
+ const node_uuid_1 = __importDefault(require("node-uuid"));
19
20
  const CACHE_TTL = 60 * 60 * 1000; // 1 hour
20
21
  const toKey = (ref) => `assetManager:asset:${ref}`;
21
22
  function enrichAsset(asset) {
@@ -180,10 +181,14 @@ class AssetManager {
180
181
  ref = (0, utils_1.normalizeKapetaUri)(ref);
181
182
  if (await codeGeneratorManager_1.codeGeneratorManager.canGenerateCode(block)) {
182
183
  const assetTitle = block.metadata.title ? block.metadata.title : (0, nodejs_utils_1.parseKapetaUri)(block.metadata.name).name;
183
- taskManager_1.taskManager.add(`codegen:${ref}`, async () => {
184
+ const taskId = `codegen:${node_uuid_1.default.v4()}`;
185
+ const group = `codegen:${ref}`;
186
+ // We group the codegen tasks since we want to run them all but only 1 at a time per block
187
+ taskManager_1.taskManager.add(taskId, async () => {
184
188
  await codeGeneratorManager_1.codeGeneratorManager.generate(ymlPath, block);
185
189
  }, {
186
190
  name: `Generating code for ${assetTitle}`,
191
+ group, //Group prevents multiple tasks from running at the same time
187
192
  });
188
193
  return true;
189
194
  }
@@ -16,6 +16,7 @@ const definitionsManager_1 = require("./definitionsManager");
16
16
  const utils_1 = require("./utils/utils");
17
17
  const taskManager_1 = require("./taskManager");
18
18
  const cacheManager_1 = require("./cacheManager");
19
+ const node_uuid_1 = __importDefault(require("node-uuid"));
19
20
  const CACHE_TTL = 60 * 60 * 1000; // 1 hour
20
21
  const toKey = (ref) => `assetManager:asset:${ref}`;
21
22
  function enrichAsset(asset) {
@@ -180,10 +181,14 @@ class AssetManager {
180
181
  ref = (0, utils_1.normalizeKapetaUri)(ref);
181
182
  if (await codeGeneratorManager_1.codeGeneratorManager.canGenerateCode(block)) {
182
183
  const assetTitle = block.metadata.title ? block.metadata.title : (0, nodejs_utils_1.parseKapetaUri)(block.metadata.name).name;
183
- taskManager_1.taskManager.add(`codegen:${ref}`, async () => {
184
+ const taskId = `codegen:${node_uuid_1.default.v4()}`;
185
+ const group = `codegen:${ref}`;
186
+ // We group the codegen tasks since we want to run them all but only 1 at a time per block
187
+ taskManager_1.taskManager.add(taskId, async () => {
184
188
  await codeGeneratorManager_1.codeGeneratorManager.generate(ymlPath, block);
185
189
  }, {
186
190
  name: `Generating code for ${assetTitle}`,
191
+ group, //Group prevents multiple tasks from running at the same time
187
192
  });
188
193
  return true;
189
194
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapeta/local-cluster-service",
3
- "version": "0.19.2",
3
+ "version": "0.19.3",
4
4
  "description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -13,6 +13,7 @@ import { normalizeKapetaUri } from './utils/utils';
13
13
  import { taskManager } from './taskManager';
14
14
  import { SourceOfChange } from './types';
15
15
  import { cacheManager } from './cacheManager';
16
+ import uuid from 'node-uuid';
16
17
 
17
18
  const CACHE_TTL = 60 * 60 * 1000; // 1 hour
18
19
 
@@ -242,13 +243,17 @@ class AssetManager {
242
243
  ref = normalizeKapetaUri(ref);
243
244
  if (await codeGeneratorManager.canGenerateCode(block)) {
244
245
  const assetTitle = block.metadata.title ? block.metadata.title : parseKapetaUri(block.metadata.name).name;
246
+ const taskId = `codegen:${uuid.v4()}`;
247
+ const group = `codegen:${ref}`;
248
+ // We group the codegen tasks since we want to run them all but only 1 at a time per block
245
249
  taskManager.add(
246
- `codegen:${ref}`,
250
+ taskId,
247
251
  async () => {
248
252
  await codeGeneratorManager.generate(ymlPath, block);
249
253
  },
250
254
  {
251
255
  name: `Generating code for ${assetTitle}`,
256
+ group, //Group prevents multiple tasks from running at the same time
252
257
  }
253
258
  );
254
259
  return true;