@friggframework/devtools 2.0.0--canary.743.81eabd1.0 → 2.0.0--canary.743.265a5cd.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.
|
@@ -35,6 +35,7 @@ const {
|
|
|
35
35
|
const { queueArnFromUrl } = require('../shared/utilities/sqs-queue-arn');
|
|
36
36
|
const {
|
|
37
37
|
declaredMaxConcurrency,
|
|
38
|
+
queueWorkerConcurrencySource,
|
|
38
39
|
queueWorkerMaximumConcurrency,
|
|
39
40
|
} = require('./queue-worker-concurrency');
|
|
40
41
|
const { bundledPrismaEngineExcludes } = require('../shared/lambda-architectures');
|
|
@@ -441,7 +442,8 @@ class IntegrationBuilder extends InfrastructureBuilder {
|
|
|
441
442
|
// Create Queue Worker function
|
|
442
443
|
const queueWorkerName = `${integrationName}QueueWorker`;
|
|
443
444
|
const queueWorkerReservedConcurrency = 20;
|
|
444
|
-
// ADR-049 section 6, 2a: the
|
|
445
|
+
// ADR-049 section 6, 2a: the integration's queueWorker setting, else
|
|
446
|
+
// the modules' maxConcurrency, caps the whole queue worker.
|
|
445
447
|
const maximumConcurrency = queueWorkerMaximumConcurrency(
|
|
446
448
|
integration,
|
|
447
449
|
queueWorkerReservedConcurrency
|
|
@@ -474,7 +476,11 @@ class IntegrationBuilder extends InfrastructureBuilder {
|
|
|
474
476
|
console.log(` ✓ Queue worker function defined`);
|
|
475
477
|
if (maximumConcurrency !== undefined) {
|
|
476
478
|
console.log(
|
|
477
|
-
` ✓ Queue worker maximumConcurrency ${maximumConcurrency}
|
|
479
|
+
` ✓ Queue worker maximumConcurrency ${maximumConcurrency} for the whole queue (${
|
|
480
|
+
queueWorkerConcurrencySource(integration).source === 'integration'
|
|
481
|
+
? 'Definition.queueWorker.maximumConcurrency'
|
|
482
|
+
: `smallest module maxConcurrency ${declaredMaxConcurrency(integration)}; set Definition.queueWorker.maximumConcurrency to change or false to turn off`
|
|
483
|
+
})`
|
|
478
484
|
);
|
|
479
485
|
}
|
|
480
486
|
}
|
|
@@ -447,6 +447,30 @@ describe('IntegrationBuilder', () => {
|
|
|
447
447
|
const result = await integrationBuilder.build(withModules(50), {});
|
|
448
448
|
expect(sqsOf(result)).not.toHaveProperty('maximumConcurrency');
|
|
449
449
|
});
|
|
450
|
+
|
|
451
|
+
const withSetting = (setting, ...limits) => {
|
|
452
|
+
const app = withModules(...limits);
|
|
453
|
+
app.integrations[0].Definition.queueWorker = {
|
|
454
|
+
maximumConcurrency: setting,
|
|
455
|
+
};
|
|
456
|
+
return app;
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
it('uses Definition.queueWorker.maximumConcurrency over the modules', async () => {
|
|
460
|
+
const result = await integrationBuilder.build(
|
|
461
|
+
withSetting(8, 3),
|
|
462
|
+
{}
|
|
463
|
+
);
|
|
464
|
+
expect(sqsOf(result).maximumConcurrency).toBe(8);
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
it('sets nothing when Definition.queueWorker.maximumConcurrency is false', async () => {
|
|
468
|
+
const result = await integrationBuilder.build(
|
|
469
|
+
withSetting(false, 3),
|
|
470
|
+
{}
|
|
471
|
+
);
|
|
472
|
+
expect(sqsOf(result)).not.toHaveProperty('maximumConcurrency');
|
|
473
|
+
});
|
|
450
474
|
});
|
|
451
475
|
|
|
452
476
|
it('should add queue URL to environment variables', async () => {
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
* `static rateLimit`. The module only describes the provider; devtools
|
|
5
5
|
* decides the deployment.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* `maximumConcurrency` limits the whole queue of the integration, for every
|
|
8
|
+
* tenant, while `maxConcurrency` describes one key of the provider. So the
|
|
9
|
+
* integration decides it: `Definition.queueWorker.maximumConcurrency` sets
|
|
10
|
+
* it (an integer), or turns it off (`false`). When the integration sets
|
|
11
|
+
* nothing, the value is the smallest `maxConcurrency` of its modules.
|
|
8
12
|
* It becomes the SQS event source's `maximumConcurrency`, which AWS bounds to
|
|
9
13
|
* 2..1000, and never more than the worker's reserved concurrency. An SQS
|
|
10
14
|
* event source that hits `maximumConcurrency` leaves the messages in the
|
|
@@ -39,13 +43,29 @@ function declaredMaxConcurrency(integration) {
|
|
|
39
43
|
return smallest;
|
|
40
44
|
}
|
|
41
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Where the value comes from: the integration's own setting, or its modules.
|
|
48
|
+
* @returns {{ value: number|undefined, source: 'integration'|'modules'|'off'|'none' }}
|
|
49
|
+
*/
|
|
50
|
+
function queueWorkerConcurrencySource(integration) {
|
|
51
|
+
const setting = integration?.Definition?.queueWorker?.maximumConcurrency;
|
|
52
|
+
if (setting === false) return { value: undefined, source: 'off' };
|
|
53
|
+
if (Number.isInteger(setting) && setting > 0) {
|
|
54
|
+
return { value: setting, source: 'integration' };
|
|
55
|
+
}
|
|
56
|
+
const declared = declaredMaxConcurrency(integration);
|
|
57
|
+
return declared === undefined
|
|
58
|
+
? { value: undefined, source: 'none' }
|
|
59
|
+
: { value: declared, source: 'modules' };
|
|
60
|
+
}
|
|
61
|
+
|
|
42
62
|
/**
|
|
43
63
|
* @returns {number|undefined} the SQS `maximumConcurrency` for the queue
|
|
44
|
-
* worker, or undefined when
|
|
64
|
+
* worker, or undefined when it is off, nothing declares a value, or the
|
|
45
65
|
* value is not below the reserved concurrency.
|
|
46
66
|
*/
|
|
47
67
|
function queueWorkerMaximumConcurrency(integration, reservedConcurrency) {
|
|
48
|
-
const declared =
|
|
68
|
+
const declared = queueWorkerConcurrencySource(integration).value;
|
|
49
69
|
if (declared === undefined) return undefined;
|
|
50
70
|
const value = Math.max(declared, SQS_MIN_MAXIMUM_CONCURRENCY);
|
|
51
71
|
return value < reservedConcurrency ? value : undefined;
|
|
@@ -54,5 +74,6 @@ function queueWorkerMaximumConcurrency(integration, reservedConcurrency) {
|
|
|
54
74
|
module.exports = {
|
|
55
75
|
SQS_MIN_MAXIMUM_CONCURRENCY,
|
|
56
76
|
declaredMaxConcurrency,
|
|
77
|
+
queueWorkerConcurrencySource,
|
|
57
78
|
queueWorkerMaximumConcurrency,
|
|
58
79
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/devtools",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.743.
|
|
4
|
+
"version": "2.0.0--canary.743.265a5cd.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"frigg": "./frigg-cli/index.js"
|
|
7
7
|
},
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"@babel/eslint-parser": "^7.18.9",
|
|
29
29
|
"@babel/parser": "^7.25.3",
|
|
30
30
|
"@babel/traverse": "^7.25.3",
|
|
31
|
-
"@friggframework/core": "2.0.0--canary.743.
|
|
32
|
-
"@friggframework/schemas": "2.0.0--canary.743.
|
|
33
|
-
"@friggframework/test": "2.0.0--canary.743.
|
|
31
|
+
"@friggframework/core": "2.0.0--canary.743.265a5cd.0",
|
|
32
|
+
"@friggframework/schemas": "2.0.0--canary.743.265a5cd.0",
|
|
33
|
+
"@friggframework/test": "2.0.0--canary.743.265a5cd.0",
|
|
34
34
|
"@hapi/boom": "^10.0.1",
|
|
35
35
|
"@inquirer/prompts": "^5.3.8",
|
|
36
36
|
"axios": "^1.18.0",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"validate-npm-package-name": "^5.0.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@friggframework/eslint-config": "2.0.0--canary.743.
|
|
62
|
-
"@friggframework/prettier-config": "2.0.0--canary.743.
|
|
61
|
+
"@friggframework/eslint-config": "2.0.0--canary.743.265a5cd.0",
|
|
62
|
+
"@friggframework/prettier-config": "2.0.0--canary.743.265a5cd.0",
|
|
63
63
|
"aws-sdk-client-mock": "^4.1.0",
|
|
64
64
|
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
65
65
|
"jest": "^30.1.3",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "265a5cd5f39515f47164aec0b99fed86048b59d9"
|
|
95
95
|
}
|