Skip to content

Commit a0d6e6d

Browse files
authored
Merge pull request #1530 from itpey/main
Add MaxRetry for MinIO operations
2 parents a5f954c + 603305c commit a0d6e6d

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

minio/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ type Config struct {
9494
// Optional. Default is false
9595
Reset bool
9696

97+
// The maximum number of times requests that encounter retryable failures should be attempted.
98+
// Optional. Default is 10, same as the MinIO client.
99+
MaxRetry int
100+
97101
// Credentials Minio access key and Minio secret key.
98102
// Need to be defined
99103
Credentials Credentials
@@ -124,6 +128,7 @@ var ConfigDefault = Config{
124128
Token: "",
125129
Secure: false,
126130
Reset: false,
131+
127132
Credentials: Credentials{},
128133
GetObjectOptions: minio.GetObjectOptions{},
129134
PutObjectOptions: minio.PutObjectOptions{},

minio/config.go

+9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ type Config struct {
2929
// Optional. Default is false
3030
Reset bool
3131

32+
// The maximum number of times requests that encounter retryable failures should be attempted.
33+
// Optional. Default is 10, same as the MinIO client.
34+
MaxRetry int
35+
3236
// Credentials Minio access key and Minio secret key.
3337
// Need to be defined
3438
Credentials Credentials
@@ -62,6 +66,7 @@ var ConfigDefault = Config{
6266
Token: "",
6367
Secure: false,
6468
Reset: false,
69+
MaxRetry: minio.MaxRetry,
6570
Credentials: Credentials{},
6671
GetObjectOptions: minio.GetObjectOptions{},
6772
PutObjectOptions: minio.PutObjectOptions{},
@@ -84,5 +89,9 @@ func configDefault(config ...Config) Config {
8489
cfg.Bucket = ConfigDefault.Bucket
8590
}
8691

92+
if cfg.MaxRetry < 1 {
93+
cfg.MaxRetry = ConfigDefault.MaxRetry
94+
}
95+
8796
return cfg
8897
}

minio/minio.go

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ func New(config ...Config) *Storage {
2828
// Set default config
2929
cfg := configDefault(config...)
3030

31+
// Set MaxRetry
32+
minio.MaxRetry = cfg.MaxRetry
33+
3134
// Minio instance
3235
minioClient, err := minio.New(cfg.Endpoint, &minio.Options{
3336
Creds: credentials.NewStaticV4(cfg.Credentials.AccessKeyID, cfg.Credentials.SecretAccessKey, cfg.Token),

0 commit comments

Comments
 (0)