Skip to content

Commit 0893db3

Browse files
committed
allow for rust options at the function level
1 parent 650de0f commit 0893db3

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
* bump lambda rust docker version to 0.1.0-rust-1.27.2
44
* speed up deployments by ~3.2 seconds by disabling excludeDevDependencies. it's on by default but it's not useful for for Rust focused services
5+
* the `custom.rust` config object can be overrided at the function level
6+
7+
```yaml
8+
functions:
9+
hello:
10+
rust:
11+
cargoFlags: '--features ...'
12+
handler: liblambda.handler
13+
package:
14+
include:
15+
- liblambda.so
16+
events:
17+
- schedule: rate(5 minutes)
18+
```
519
620
# 0.1.3
721

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ServerlessPlugin {
3838
this.artifacts = [];
3939
}
4040

41-
runDocker(args, captureOutput) {
41+
runDocker(funcArgs, captureOutput) {
4242
const defaultArgs = [
4343
'run',
4444
'--rm',
@@ -47,9 +47,10 @@ class ServerlessPlugin {
4747
`-v`, `${process.env['HOME']}/.cargo/git:/root/.cargo/git`,
4848
];
4949
const customArgs = [];
50-
if (this.custom.cargoFlags) {
50+
const cargoFlags = (funcArgs || {}).cargoFlags || this.custom.cargoFlags;
51+
if (cargoFlags) {
5152
// --features python3-sys, ect
52-
customArgs.push('-e', `CARGO_FLAGS=${this.custom.cargoFlags}`);
53+
customArgs.push('-e', `CARGO_FLAGS=${cargoFlags}`);
5354
};
5455
return spawnSync(
5556
'docker',
@@ -68,7 +69,7 @@ class ServerlessPlugin {
6869
const func = service.getFunction(funcName);
6970
const [crate, fn] = func.handler.split('.');
7071
this.serverless.cli.log(`Building native Rust ${func.handler} func...`);
71-
const res = this.runDocker();
72+
const res = this.runDocker(func.rust);
7273
if (res.error || res.status > 0) {
7374
this.serverless.cli.log(`Dockerized Rust build encountered an error.`);
7475
throw new Error(res.error);

0 commit comments

Comments
 (0)