serverless-plugin-warmup 7.0.0 → 7.0.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.
- package/package.json +2 -2
- package/src/index.js +19 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serverless-plugin-warmup",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"description": "Keep your lambdas warm during winter.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
36
36
|
"eslint-plugin-import": "^2.24.2",
|
|
37
37
|
"husky": "^7.0.2",
|
|
38
|
-
"jest": "^27.
|
|
38
|
+
"jest": "^27.5.0"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/index.js
CHANGED
|
@@ -71,8 +71,8 @@ class WarmUp {
|
|
|
71
71
|
'warmup:cleanupTempDir:cleanup': this.cleanUp.bind(this),
|
|
72
72
|
'before:warmup:prewarm:start': this.configPlugin.bind(this),
|
|
73
73
|
'warmup:prewarm:start': this.prewarmFunctions.bind(this),
|
|
74
|
-
// Workaround webpack/bundle plugins
|
|
75
|
-
'before:package:createDeploymentArtifacts': this.
|
|
74
|
+
// Workaround webpack/bundle plugins and serverless_sdk
|
|
75
|
+
'before:package:createDeploymentArtifacts': this.resetWarmerConfigs.bind(this),
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
// Fixed for issues in Serverles
|
|
@@ -102,6 +102,23 @@ class WarmUp {
|
|
|
102
102
|
.map(([warmerName, warmerConfig]) => this.configureWarmer(warmerName, warmerConfig)));
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
/**
|
|
106
|
+
* @description Workaround webpack/bundle plugins and serverless_sdk.
|
|
107
|
+
* Reset the plugin and ignore changes
|
|
108
|
+
*
|
|
109
|
+
* @fulfil {} — Warm up set
|
|
110
|
+
* @reject {Error} Warm up error
|
|
111
|
+
*
|
|
112
|
+
* @return {Promise}
|
|
113
|
+
* */
|
|
114
|
+
async resetWarmerConfigs() {
|
|
115
|
+
await Promise.all(Object.entries(this.configsByWarmer)
|
|
116
|
+
.map(([
|
|
117
|
+
warmerName,
|
|
118
|
+
warmerConfig,
|
|
119
|
+
]) => addWarmUpFunctionToService(this.serverless.service, warmerName, warmerConfig)));
|
|
120
|
+
}
|
|
121
|
+
|
|
105
122
|
/**
|
|
106
123
|
* @description Warmup cleanup hook.
|
|
107
124
|
*
|
|
@@ -178,12 +195,6 @@ class WarmUp {
|
|
|
178
195
|
return;
|
|
179
196
|
}
|
|
180
197
|
|
|
181
|
-
// Avoid double processing due to the workaround for webpack/bundle plugins
|
|
182
|
-
// resetting the plugin and ignoring changes
|
|
183
|
-
if (this.serverless.service.functions[`warmUpPlugin${capitalize(warmerName)}`]) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
198
|
this.log.notice(`WarmUp: Creating warmer "${warmerName}" to warm up ${warmerConfig.functions.length} function${warmerConfig.functions.length === 1 ? '' : 's'}`);
|
|
188
199
|
this.log.info(':');
|
|
189
200
|
warmerConfig.functions.forEach((func) => this.log.info(` * ${func.name}`));
|