Skip to content

Commit 8b5d69d

Browse files
Skn0ttbiruwon
andauthored
feat: support function timeout property (#537)
Co-authored-by: Antonio Rodríguez <[email protected]>
1 parent 809b829 commit 8b5d69d

File tree

5 files changed

+52
-14
lines changed

5 files changed

+52
-14
lines changed

go/plumbing/operations/upload_deploy_function_parameters.go

+41-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/porcelain/deploy.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ type FileBundle struct {
127127

128128
type FunctionMetadata struct {
129129
InvocationMode string
130+
Timeout int64
130131
}
131132

132133
type toolchainSpec struct {
@@ -536,10 +537,11 @@ func (n *Netlify) uploadFile(ctx context.Context, d *models.Deploy, f *FileBundl
536537

537538
if f.FunctionMetadata != nil {
538539
params = params.WithInvocationMode(&f.FunctionMetadata.InvocationMode)
540+
params = params.WithTimeout(&f.FunctionMetadata.Timeout)
539541
}
540542

541543
if timeout != 0 {
542-
params.SetTimeout(timeout)
544+
params.SetRequestTimeout(timeout)
543545
}
544546
_, operationError = n.Operations.UploadDeployFunction(params, authInfo)
545547
if operationError != nil {
@@ -797,6 +799,7 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
797799

798800
meta := FunctionMetadata{
799801
InvocationMode: function.InvocationMode,
802+
Timeout: function.Timeout,
800803
}
801804
file, err := newFunctionFile(function.Path, fileInfo, runtime, &meta, observer)
802805

@@ -822,7 +825,7 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
822825
}
823826
}
824827

825-
hasConfig := function.DisplayName != "" || function.Generator != "" || len(routes) > 0 || len(function.BuildData) > 0 || function.Priority != 0 || function.TrafficRules != nil
828+
hasConfig := function.DisplayName != "" || function.Generator != "" || len(routes) > 0 || len(function.BuildData) > 0 || function.Priority != 0 || function.TrafficRules != nil || function.Timeout != 0
826829
if hasConfig {
827830
cfg := models.FunctionConfig{
828831
DisplayName: function.DisplayName,

go/porcelain/deploy_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ func TestBundleWithManifest(t *testing.T) {
646646
"mainFile": "/some/path/hello-js-function-test.js",
647647
"displayName": "Hello Javascript Function",
648648
"generator": "@netlify/[email protected]",
649+
"timeout": 60,
649650
"buildData": { "runtimeAPIVersion": 2 },
650651
"name": "hello-js-function-test",
651652
"schedule": "* * * * *",
@@ -693,6 +694,7 @@ func TestBundleWithManifest(t *testing.T) {
693694
assert.Equal(t, 3, len(functions.Files))
694695
assert.Equal(t, "a-runtime", functions.Files["hello-js-function-test"].Runtime)
695696
assert.Empty(t, functions.Files["hello-js-function-test"].FunctionMetadata.InvocationMode)
697+
assert.Equal(t, int64(60), functions.Files["hello-js-function-test"].FunctionMetadata.Timeout)
696698
assert.Equal(t, "some-other-runtime", functions.Files["hello-py-function-test"].Runtime)
697699
assert.Equal(t, "stream", functions.Files["hello-py-function-test"].FunctionMetadata.InvocationMode)
698700
assert.Equal(t, "provided.al2", functions.Files["hello-go-binary-function"].Runtime)

go/porcelain/functions_manifest.go

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type functionsManifestEntry struct {
1717
Schedule string `json:"schedule"`
1818
DisplayName string `json:"displayName"`
1919
Generator string `json:"generator"`
20+
Timeout int64 `json:"timeout"`
2021
BuildData map[string]interface{} `json:"buildData"`
2122
InvocationMode string `json:"invocationMode"`
2223
Routes []functionRoute `json:"routes"`

swagger.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,9 @@ paths:
14781478
- name: invocation_mode
14791479
in: query
14801480
type: string
1481+
- name: timeout
1482+
in: query
1483+
type: integer
14811484
- name: size
14821485
type: integer
14831486
in: query

0 commit comments

Comments
 (0)