@swydo/byol 2.0.37 → 2.1.2
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 +20 -1
- package/package.json +2 -2
- package/src/handlerWorkerPool.js +17 -13
- package/src/invokeFunction.js +2 -0
- package/src/invokeHandler.js +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## 2.
|
|
6
|
+
## 2.1.2 (2022-04-25)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @swydo/byol
|
|
9
9
|
|
|
@@ -11,6 +11,25 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
+
## 2.1.1 (2022-04-25)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @swydo/byol
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# 2.1.0 (2022-04-22)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* support `--inspect` to enable attaching a debugger to child processes ([#376](https://github.com/Swydo/byol/issues/376)) ([097d139](https://github.com/Swydo/byol/commit/097d139f1690b64a3a994cd2c4fa44be7a61e49d))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
14
33
|
## 2.0.36 (2022-04-22)
|
|
15
34
|
|
|
16
35
|
**Note:** Version bump only for package @swydo/byol
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swydo/byol",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Bring Your Own Lambda",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"aws-xray-sdk-core": "^3.0.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "f5ccc250d19b311bcd317943ce66a18945d88e3c"
|
|
31
31
|
}
|
package/src/handlerWorkerPool.js
CHANGED
|
@@ -3,16 +3,16 @@ const workerpool = require('workerpool');
|
|
|
3
3
|
|
|
4
4
|
const workerPoolMap = new Map();
|
|
5
5
|
|
|
6
|
-
function getWorkerPoolKey(
|
|
6
|
+
function getWorkerPoolKey(indexPath, handlerName, requestId, poolOptions) {
|
|
7
7
|
if (requestId) {
|
|
8
|
-
return `${
|
|
8
|
+
return `${indexPath}:${handlerName}:${requestId}:${JSON.stringify(poolOptions)}`;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
return `${
|
|
11
|
+
return `${indexPath}:${handlerName}:${JSON.stringify(poolOptions)}`;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function terminateWorkerPool(
|
|
15
|
-
const poolKey = getWorkerPoolKey(
|
|
14
|
+
function terminateWorkerPool(indexPath, handlerName, requestId, poolOptions) {
|
|
15
|
+
const poolKey = getWorkerPoolKey(indexPath, handlerName, requestId, poolOptions);
|
|
16
16
|
|
|
17
17
|
const { pool } = workerPoolMap.get(poolKey);
|
|
18
18
|
const terminationPromise = pool.terminate();
|
|
@@ -26,22 +26,25 @@ function terminateWorkerPools() {
|
|
|
26
26
|
const terminationPromises = [];
|
|
27
27
|
|
|
28
28
|
workerPoolMap.forEach((pool) => {
|
|
29
|
-
const {
|
|
30
|
-
|
|
29
|
+
const {
|
|
30
|
+
absoluteIndexPath,
|
|
31
|
+
handlerName,
|
|
32
|
+
requestId,
|
|
33
|
+
poolOptions,
|
|
34
|
+
} = pool;
|
|
35
|
+
terminationPromises.push(terminateWorkerPool(absoluteIndexPath, handlerName, requestId, poolOptions));
|
|
31
36
|
});
|
|
32
37
|
|
|
33
38
|
return Promise.all(terminationPromises);
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
async function getWorkerPool(
|
|
37
|
-
const poolKey = getWorkerPoolKey(
|
|
41
|
+
async function getWorkerPool(indexPath, handlerName, environment = {}, requestId, poolOptions = {}) {
|
|
42
|
+
const poolKey = getWorkerPoolKey(indexPath, handlerName, requestId, poolOptions);
|
|
38
43
|
|
|
39
44
|
if (!workerPoolMap.has(poolKey)) {
|
|
40
45
|
const pool = workerpool.pool(path.join(__dirname, 'assets', 'callHandlerProcess.js'), {
|
|
41
46
|
workerType: 'process',
|
|
42
|
-
|
|
43
|
-
cwd: workingDirectory,
|
|
44
|
-
},
|
|
47
|
+
...poolOptions,
|
|
45
48
|
});
|
|
46
49
|
|
|
47
50
|
workerPoolMap.set(poolKey, {
|
|
@@ -50,6 +53,7 @@ async function getWorkerPool(workingDirectory, indexPath, handlerName, environme
|
|
|
50
53
|
handlerName,
|
|
51
54
|
environment,
|
|
52
55
|
requestId,
|
|
56
|
+
poolOptions,
|
|
53
57
|
});
|
|
54
58
|
}
|
|
55
59
|
|
|
@@ -58,7 +62,7 @@ async function getWorkerPool(workingDirectory, indexPath, handlerName, environme
|
|
|
58
62
|
if (JSON.stringify(poolEnvironment) !== JSON.stringify(environment)) {
|
|
59
63
|
terminateWorkerPool(poolKey);
|
|
60
64
|
|
|
61
|
-
return getWorkerPool(
|
|
65
|
+
return getWorkerPool(indexPath, handlerName, environment, requestId, poolOptions);
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
return pool;
|
package/src/invokeFunction.js
CHANGED
|
@@ -41,6 +41,7 @@ function getAwsEnvironment({ profile, region }) {
|
|
|
41
41
|
async function invokeFunction(functionName, event, {
|
|
42
42
|
templatePath = path.join(process.cwd(), 'template.yml'),
|
|
43
43
|
envPath = path.join(process.cwd(), 'env.json'),
|
|
44
|
+
debugPortStart,
|
|
44
45
|
region,
|
|
45
46
|
requestId,
|
|
46
47
|
keepAlive = false,
|
|
@@ -66,6 +67,7 @@ async function invokeFunction(functionName, event, {
|
|
|
66
67
|
|
|
67
68
|
const options = {
|
|
68
69
|
indexPath,
|
|
70
|
+
debugPortStart,
|
|
69
71
|
handlerName,
|
|
70
72
|
environment,
|
|
71
73
|
event,
|
package/src/invokeHandler.js
CHANGED
|
@@ -7,6 +7,7 @@ function getDebug(requestId) {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
async function invokeHandler({
|
|
10
|
+
debugPortStart,
|
|
10
11
|
indexPath,
|
|
11
12
|
handlerName,
|
|
12
13
|
environment,
|
|
@@ -19,7 +20,13 @@ async function invokeHandler({
|
|
|
19
20
|
const debug = getDebug(id);
|
|
20
21
|
|
|
21
22
|
const poolRequestId = keepAlive ? undefined : id;
|
|
22
|
-
const
|
|
23
|
+
const poolOptions = {
|
|
24
|
+
debugPortStart,
|
|
25
|
+
forkOpts: {
|
|
26
|
+
cwd: workingDirectory,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const workerPool = await getWorkerPool(indexPath, handlerName, environment, poolRequestId, poolOptions);
|
|
23
30
|
|
|
24
31
|
try {
|
|
25
32
|
debug('Start');
|
|
@@ -45,7 +52,7 @@ async function invokeHandler({
|
|
|
45
52
|
throw e;
|
|
46
53
|
} finally {
|
|
47
54
|
if (!keepAlive) {
|
|
48
|
-
await terminateWorkerPool(
|
|
55
|
+
await terminateWorkerPool(indexPath, handlerName, poolRequestId, poolOptions);
|
|
49
56
|
}
|
|
50
57
|
}
|
|
51
58
|
}
|