Skip to content

Commit

Permalink
Add MaxRetry for MinIO operations
Browse files Browse the repository at this point in the history
  • Loading branch information
itpey committed Nov 13, 2024
1 parent a5f954c commit cb10688
Show file tree
Hide file tree
Showing 3 changed files with 13 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
5 changes: 5 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 Down
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 cb10688

Please sign in to comment.