@middy/warmup 4.0.0 → 4.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/README.md +0 -54
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -36,60 +36,6 @@
|
|
|
36
36
|
<p>You can read the documentation at: <a href="https://middy.js.org/docs/middlewares/warmup">https://middy.js.org/docs/middlewares/warmup</a></p>
|
|
37
37
|
</div>
|
|
38
38
|
|
|
39
|
-
Warmup middleware that helps to reduce the [cold-start issue](https://serverless.com/blog/keep-your-lambdas-warm/). Compatible by default with [`serverless-plugin-warmup`](https://www.npmjs.com/package/serverless-plugin-warmup), but it can be configured to suit your implementation.
|
|
40
|
-
|
|
41
|
-
This middleware allows you to specify a schedule to keep Lambdas that always need to be very responsive warmed-up. It does this by regularly invoking the Lambda, but will terminate early to avoid the actual handler logic from being run.
|
|
42
|
-
|
|
43
|
-
If you use [`serverless-plugin-warmup`](https://www.npmjs.com/package/serverless-plugin-warmup) the scheduling part is done by the plugin and you just have to attach the middleware to your "middyfied" handler. If you don't want to use the plugin you have to create the schedule yourself and define the `isWarmingUp` function to define whether the current event is a warmup event or an actual business logic execution.
|
|
44
|
-
|
|
45
|
-
**Important:** AWS recently announced Lambda [Provisioned Concurrency](https://aws.amazon.com/about-aws/whats-new/2019/12/aws-lambda-announces-provisioned-concurrency/). If you have this enabled, you do not need this middleware.
|
|
46
|
-
|
|
47
|
-
To update your code to use Provisioned Concurrency see:
|
|
48
|
-
- [AWS Console](https://aws.amazon.com/blogs/compute/new-for-aws-lambda-predictable-start-up-times-with-provisioned-concurrency/)
|
|
49
|
-
- [Serverless](https://serverless.com/blog/aws-lambda-provisioned-concurrency/)
|
|
50
|
-
- [Terraform](https://www.terraform.io/docs/providers/aws/r/lambda_provisioned_concurrency_config.html)
|
|
51
|
-
|
|
52
|
-
## Install
|
|
53
|
-
|
|
54
|
-
To install this middleware you can use NPM:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
npm install --save @middy/warmup
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
## Options
|
|
62
|
-
|
|
63
|
-
- `isWarmingUp`: (function) a function that accepts the `event` object as a parameter
|
|
64
|
-
and returns `true` if the current event is a warmup event and `false` if it's a regular execution. The default function will check if the `event` object has a `source` property set to `serverless-plugin-warmup`.
|
|
65
|
-
|
|
66
|
-
## Sample usage
|
|
67
|
-
|
|
68
|
-
```javascript
|
|
69
|
-
import middy from '@middy/core'
|
|
70
|
-
import warmup from '@middy/warmup'
|
|
71
|
-
|
|
72
|
-
const isWarmingUp = (event) => event.isWarmingUp === true
|
|
73
|
-
|
|
74
|
-
const originalHandler = (event, context, cb) => {
|
|
75
|
-
/* ... */
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const handler = middy(originalHandler)
|
|
79
|
-
.use(warmup({ isWarmingUp }))
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
## Middy documentation and examples
|
|
84
|
-
|
|
85
|
-
For more documentation and examples, refers to the main [Middy monorepo on GitHub](https://github.com/middyjs/middy) or [Middy official website](https://middy.js.org).
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
## Contributing
|
|
89
|
-
|
|
90
|
-
Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/middyjs/middy/issues) or to [submit Pull Requests](https://github.com/middyjs/middy/pulls).
|
|
91
|
-
|
|
92
|
-
|
|
93
39
|
## License
|
|
94
40
|
|
|
95
41
|
Licensed under [MIT License](LICENSE). Copyright (c) 2017-2022 [Luciano Mammino](https://github.com/lmammino), [will Farrell](https://github.com/willfarrell), and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/warmup",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Warmup (cold start mitigation) middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"homepage": "https://middy.js.org",
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@middy/core": "4.0.
|
|
65
|
+
"@middy/core": "4.0.1"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "c5ece2bfbb0d607dcdea5685bf194a6cc19acc8d"
|
|
68
68
|
}
|