Skip to content

Commit

Permalink
set server-side timeout for GET requests
Browse files Browse the repository at this point in the history
  • Loading branch information
anshrupani committed Dec 18, 2023
1 parent e862d39 commit 759862b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (client *AzBlobstore) Sign(dest string, action string, expiration time.Dura
action = strings.ToUpper(action)
switch action {
case "GET", "PUT":
return client.storageClient.SignedUrl(dest, expiration)
return client.storageClient.SignedUrl(action, dest, expiration)
default:
return "", fmt.Errorf("action not implemented: %s", action)
}
Expand Down
3 changes: 2 additions & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ var _ = Describe("Client", func() {
Expect(url == "https://the-signed-url").To(BeTrue())
Expect(err).ToNot(HaveOccurred())

dest, expiration := storageClient.SignedUrlArgsForCall(0)
action, dest, expiration := storageClient.SignedUrlArgsForCall(0)
Expect(action).To(Equal("GET"))
Expect(dest).To(Equal("blob"))
Expect(int(expiration)).To(Equal(100))
})
Expand Down
22 changes: 12 additions & 10 deletions client/clientfakes/fake_storage_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions client/storage_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type StorageClient interface {
) (bool, error)

SignedUrl(
requestType string,
dest string,
expiration time.Duration,
) (string, error)
Expand Down Expand Up @@ -152,6 +153,7 @@ func (dsc DefaultStorageClient) Exists(
}

func (dsc DefaultStorageClient) SignedUrl(
requestType string,
dest string,
expiration time.Duration,
) (string, error) {
Expand All @@ -169,5 +171,9 @@ func (dsc DefaultStorageClient) SignedUrl(
return "", err
}

if requestType == "GET" {
url = url + "&timeout=1800"
}

return url, err
}

0 comments on commit 759862b

Please sign in to comment.