Skip to content

Commit 3e9a664

Browse files
authored
Merge pull request #33 from cpuguy83/set_azblob_retries
Set custom values for azblob retries
2 parents 1a5174a + 3136d0f commit 3e9a664

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

cache_v2.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import (
55
"context"
66
"encoding/json"
77
"io"
8+
"time"
89

10+
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
11+
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
912
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
1013
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blockblob"
1114
"github.com/pkg/errors"
@@ -45,8 +48,18 @@ func (c *Cache) reserveV2(ctx context.Context, key string) (string, error) {
4548
return cr.SignedUploadURL, nil
4649
}
4750

51+
var azureOptions = &blockblob.ClientOptions{
52+
ClientOptions: azcore.ClientOptions{
53+
Retry: policy.RetryOptions{
54+
MaxRetries: 10,
55+
MaxRetryDelay: 2 * time.Minute,
56+
RetryDelay: 10 * time.Second,
57+
},
58+
},
59+
}
60+
4861
func (c *Cache) uploadV2(ctx context.Context, url string, b Blob) error {
49-
client, err := blockblob.NewClientWithNoCredential(url, nil)
62+
client, err := blockblob.NewClientWithNoCredential(url, azureOptions)
5063
if err != nil {
5164
return errors.WithStack(err)
5265
}
@@ -62,7 +75,7 @@ func (c *Cache) uploadV2(ctx context.Context, url string, b Blob) error {
6275

6376
func (ce *Entry) downloadV2(ctx context.Context) ReaderAtCloser {
6477
return toReaderAtCloser(func(offset int64) (io.ReadCloser, error) {
65-
client, err := blockblob.NewClientWithNoCredential(ce.URL, nil)
78+
client, err := blockblob.NewClientWithNoCredential(ce.URL, azureOptions)
6679
if err != nil {
6780
return nil, errors.WithStack(err)
6881
}

0 commit comments

Comments
 (0)