Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit 0a5404c

Browse files
committed
Add support for concurrent activations
1 parent cb1ea67 commit 0a5404c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,7 @@ functions:
731731
namespace: "..." // defaults to user-provided credentials
732732
memory: 256 // 128 to 512 (MB).
733733
timeout: 60 // 0.1 to 600 (seconds)
734+
concurrency: 1 // 1 to 500, default is 1
734735
parameters:
735736
foo: bar // default parameters
736737
annotations:

compile/functions/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ class OpenWhiskCompileFunctions {
5454
return functionObject.memory || this.serverless.service.provider.memory || 256;
5555
}
5656

57+
calculateConcurrency(functionObject) {
58+
return functionObject.concurrency || this.serverless.service.provider.concurrency || 1;
59+
}
60+
5761
calculateTimeout(functionObject) {
5862
return functionObject.timeout || this.serverless.service.provider.timeout || 60;
5963
}
@@ -77,7 +81,11 @@ class OpenWhiskCompileFunctions {
7781
overwrite: params.Overwrite,
7882
action: {
7983
exec: params.Exec,
80-
limits: { timeout: params.Timeout * 1000, memory: params.MemorySize },
84+
limits: {
85+
timeout: params.Timeout * 1000,
86+
memory: params.MemorySize,
87+
concurrency: params.Concurrency,
88+
},
8189
parameters: params.Parameters,
8290
annotations: params.Annotations
8391
},
@@ -99,6 +107,7 @@ class OpenWhiskCompileFunctions {
99107
const MemorySize = this.calculateMemorySize(functionObject);
100108
const Timeout = this.calculateTimeout(functionObject);
101109
const Overwrite = this.calculateOverwrite(functionObject);
110+
const Concurrency = this.calculateConcurrency(functionObject);
102111

103112
// optional action parameters
104113
const Parameters = Object.keys(functionObject.parameters || {})
@@ -108,7 +117,7 @@ class OpenWhiskCompileFunctions {
108117
const Annotations = this.constructAnnotations(functionObject.annotations);
109118

110119
return this.compileFunctionAction(
111-
{ FunctionName, NameSpace, Overwrite, Exec, Timeout, MemorySize, Parameters, Annotations }
120+
{ FunctionName, NameSpace, Overwrite, Exec, Timeout, MemorySize, Concurrency, Parameters, Annotations }
112121
);
113122
});
114123
}

0 commit comments

Comments
 (0)