@friggframework/devtools 2.0.0--canary.743.81eabd1.0 → 2.0.0--canary.743.a254104.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
|
|
@@ -472,9 +474,22 @@ class IntegrationBuilder extends InfrastructureBuilder {
|
|
|
472
474
|
timeout: 900, // 15 minutes max for queue workers (Lambda maximum)
|
|
473
475
|
};
|
|
474
476
|
console.log(` ✓ Queue worker function defined`);
|
|
477
|
+
const concurrencySource = queueWorkerConcurrencySource(integration);
|
|
478
|
+
if (
|
|
479
|
+
maximumConcurrency === undefined &&
|
|
480
|
+
concurrencySource.value !== undefined
|
|
481
|
+
) {
|
|
482
|
+
console.log(
|
|
483
|
+
` ⚠ Queue worker maximumConcurrency ${concurrencySource.value} not set: it is not below the reserved concurrency of ${queueWorkerReservedConcurrency}`
|
|
484
|
+
);
|
|
485
|
+
}
|
|
475
486
|
if (maximumConcurrency !== undefined) {
|
|
476
487
|
console.log(
|
|
477
|
-
` ✓ Queue worker maximumConcurrency ${maximumConcurrency}
|
|
488
|
+
` ✓ Queue worker maximumConcurrency ${maximumConcurrency} for the whole queue (${
|
|
489
|
+
concurrencySource.source === 'integration'
|
|
490
|
+
? 'Definition.queueWorker.maximumConcurrency'
|
|
491
|
+
: `smallest module maxConcurrency ${declaredMaxConcurrency(integration)}; set Definition.queueWorker.maximumConcurrency to change or false to turn off`
|
|
492
|
+
})`
|
|
478
493
|
);
|
|
479
494
|
}
|
|
480
495
|
}
|
|
@@ -447,6 +447,36 @@ 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('refuses a Definition.queueWorker.maximumConcurrency that is not an integer or false', async () => {
|
|
468
|
+
await expect(
|
|
469
|
+
integrationBuilder.build(withSetting('8', 3), {})
|
|
470
|
+
).rejects.toThrow('must be an integer from 2 to 1000, or false');
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
it('sets nothing when Definition.queueWorker.maximumConcurrency is false', async () => {
|
|
474
|
+
const result = await integrationBuilder.build(
|
|
475
|
+
withSetting(false, 3),
|
|
476
|
+
{}
|
|
477
|
+
);
|
|
478
|
+
expect(sqsOf(result)).not.toHaveProperty('maximumConcurrency');
|
|
479
|
+
});
|
|
450
480
|
});
|
|
451
481
|
|
|
452
482
|
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,35 @@ 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
|
+
* Throws for a setting that is neither a positive integer nor `false`.
|
|
49
|
+
* @returns {{ value: number|undefined, source: 'integration'|'modules'|'off'|'none' }}
|
|
50
|
+
*/
|
|
51
|
+
function queueWorkerConcurrencySource(integration) {
|
|
52
|
+
const setting = integration?.Definition?.queueWorker?.maximumConcurrency;
|
|
53
|
+
if (setting === false) return { value: undefined, source: 'off' };
|
|
54
|
+
if (Number.isInteger(setting) && setting > 0) {
|
|
55
|
+
return { value: setting, source: 'integration' };
|
|
56
|
+
}
|
|
57
|
+
if (setting !== undefined) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
`Definition.queueWorker.maximumConcurrency of integration "${integration?.Definition?.name}" must be an integer from 2 to 1000, or false`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
const declared = declaredMaxConcurrency(integration);
|
|
63
|
+
return declared === undefined
|
|
64
|
+
? { value: undefined, source: 'none' }
|
|
65
|
+
: { value: declared, source: 'modules' };
|
|
66
|
+
}
|
|
67
|
+
|
|
42
68
|
/**
|
|
43
69
|
* @returns {number|undefined} the SQS `maximumConcurrency` for the queue
|
|
44
|
-
* worker, or undefined when
|
|
70
|
+
* worker, or undefined when it is off, nothing declares a value, or the
|
|
45
71
|
* value is not below the reserved concurrency.
|
|
46
72
|
*/
|
|
47
73
|
function queueWorkerMaximumConcurrency(integration, reservedConcurrency) {
|
|
48
|
-
const declared =
|
|
74
|
+
const declared = queueWorkerConcurrencySource(integration).value;
|
|
49
75
|
if (declared === undefined) return undefined;
|
|
50
76
|
const value = Math.max(declared, SQS_MIN_MAXIMUM_CONCURRENCY);
|
|
51
77
|
return value < reservedConcurrency ? value : undefined;
|
|
@@ -54,5 +80,6 @@ function queueWorkerMaximumConcurrency(integration, reservedConcurrency) {
|
|
|
54
80
|
module.exports = {
|
|
55
81
|
SQS_MIN_MAXIMUM_CONCURRENCY,
|
|
56
82
|
declaredMaxConcurrency,
|
|
83
|
+
queueWorkerConcurrencySource,
|
|
57
84
|
queueWorkerMaximumConcurrency,
|
|
58
85
|
};
|
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.a254104.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.a254104.0",
|
|
32
|
+
"@friggframework/schemas": "2.0.0--canary.743.a254104.0",
|
|
33
|
+
"@friggframework/test": "2.0.0--canary.743.a254104.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.a254104.0",
|
|
62
|
+
"@friggframework/prettier-config": "2.0.0--canary.743.a254104.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": "a25410415a2aed83688bd93a995f1185ee722501"
|
|
95
95
|
}
|