Skip to content

Commit

Permalink
Merge pull request #1530 from itpey/main
Browse files Browse the repository at this point in the history
Add MaxRetry for MinIO operations
  • Loading branch information
ReneWerner87 authored Nov 14, 2024
2 parents a5f954c + 603305c commit a0d6e6d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions minio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ type Config struct {
// Optional. Default is false
Reset bool

// The maximum number of times requests that encounter retryable failures should be attempted.
// Optional. Default is 10, same as the MinIO client.
MaxRetry int

// Credentials Minio access key and Minio secret key.
// Need to be defined
Credentials Credentials
Expand Down Expand Up @@ -124,6 +128,7 @@ var ConfigDefault = Config{
Token: "",
Secure: false,
Reset: false,

Credentials: Credentials{},
GetObjectOptions: minio.GetObjectOptions{},
PutObjectOptions: minio.PutObjectOptions{},
Expand Down
9 changes: 9 additions & 0 deletions minio/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ type Config struct {
// Optional. Default is false
Reset bool

// The maximum number of times requests that encounter retryable failures should be attempted.
// Optional. Default is 10, same as the MinIO client.
MaxRetry int

// Credentials Minio access key and Minio secret key.
// Need to be defined
Credentials Credentials
Expand Down Expand Up @@ -62,6 +66,7 @@ var ConfigDefault = Config{
Token: "",
Secure: false,
Reset: false,
MaxRetry: minio.MaxRetry,
Credentials: Credentials{},
GetObjectOptions: minio.GetObjectOptions{},
PutObjectOptions: minio.PutObjectOptions{},
Expand All @@ -84,5 +89,9 @@ func configDefault(config ...Config) Config {
cfg.Bucket = ConfigDefault.Bucket
}

if cfg.MaxRetry < 1 {
cfg.MaxRetry = ConfigDefault.MaxRetry
}

return cfg
}
3 changes: 3 additions & 0 deletions minio/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func New(config ...Config) *Storage {
// Set default config
cfg := configDefault(config...)

// Set MaxRetry
minio.MaxRetry = cfg.MaxRetry

// Minio instance
minioClient, err := minio.New(cfg.Endpoint, &minio.Options{
Creds: credentials.NewStaticV4(cfg.Credentials.AccessKeyID, cfg.Credentials.SecretAccessKey, cfg.Token),
Expand Down

0 comments on commit a0d6e6d

Please sign in to comment.