Skip to content

Commit c417084

Browse files
committed
refactor: move timeout to query param
1 parent 8c2131e commit c417084

File tree

6 files changed

+50
-21
lines changed

6 files changed

+50
-21
lines changed

go/models/function_config.go

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

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

+4-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

@@ -830,7 +833,6 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
830833
Routes: routes,
831834
BuildData: function.BuildData,
832835
Priority: int64(function.Priority),
833-
Timeout: int64(function.Timeout),
834836
}
835837

836838
if function.TrafficRules != nil {

go/porcelain/deploy_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ func TestBundleWithManifest(t *testing.T) {
694694
assert.Equal(t, 3, len(functions.Files))
695695
assert.Equal(t, "a-runtime", functions.Files["hello-js-function-test"].Runtime)
696696
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)
697698
assert.Equal(t, "some-other-runtime", functions.Files["hello-py-function-test"].Runtime)
698699
assert.Equal(t, "stream", functions.Files["hello-py-function-test"].FunctionMetadata.InvocationMode)
699700
assert.Equal(t, "provided.al2", functions.Files["hello-go-binary-function"].Runtime)
@@ -704,7 +705,6 @@ func TestBundleWithManifest(t *testing.T) {
704705
assert.Equal(t, 1, len(functionsConfig))
705706
assert.Equal(t, "Hello Javascript Function", helloJSConfig.DisplayName)
706707
assert.Equal(t, "@netlify/[email protected]", helloJSConfig.Generator)
707-
assert.Equal(t, int64(60), helloJSConfig.Timeout)
708708
assert.EqualValues(t, 2, helloJSConfig.BuildData.(map[string]interface{})["runtimeAPIVersion"])
709709

710710
assert.Equal(t, "/products", helloJSConfig.Routes[0].Pattern)

go/porcelain/functions_manifest.go

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

swagger.yml

+3-2
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
@@ -3859,8 +3862,6 @@ definitions:
38593862
type: string
38603863
generator:
38613864
type: string
3862-
timeout:
3863-
type: integer
38643865
build_data:
38653866
type: object
38663867
routes:

0 commit comments

Comments
 (0)