From cb106882f0589ca71d930b0bf8e36548fe8dbcab Mon Sep 17 00:00:00 2001 From: itpey <52120725+itpey@users.noreply.github.com> Date: Wed, 13 Nov 2024 23:59:13 +0330 Subject: [PATCH 1/3] Add MaxRetry for MinIO operations --- minio/README.md | 5 +++++ minio/config.go | 5 +++++ minio/minio.go | 3 +++ 3 files changed, 13 insertions(+) diff --git a/minio/README.md b/minio/README.md index 0bbc9480..ec23a51c 100644 --- a/minio/README.md +++ b/minio/README.md @@ -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 @@ -124,6 +128,7 @@ var ConfigDefault = Config{ Token: "", Secure: false, Reset: false, + Credentials: Credentials{}, GetObjectOptions: minio.GetObjectOptions{}, PutObjectOptions: minio.PutObjectOptions{}, diff --git a/minio/config.go b/minio/config.go index d1976d7c..a2a0c36b 100644 --- a/minio/config.go +++ b/minio/config.go @@ -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 @@ -62,6 +66,7 @@ var ConfigDefault = Config{ Token: "", Secure: false, Reset: false, + MaxRetry: minio.MaxRetry, Credentials: Credentials{}, GetObjectOptions: minio.GetObjectOptions{}, PutObjectOptions: minio.PutObjectOptions{}, diff --git a/minio/minio.go b/minio/minio.go index 84127324..f2ffc2eb 100644 --- a/minio/minio.go +++ b/minio/minio.go @@ -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), From f9f9ee673400461e18a186afd7615a8a005a9644 Mon Sep 17 00:00:00 2001 From: itpey <52120725+itpey@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:08:02 +0330 Subject: [PATCH 2/3] Set default MaxRetry value in configDefault --- minio/config.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/minio/config.go b/minio/config.go index a2a0c36b..b096b58d 100644 --- a/minio/config.go +++ b/minio/config.go @@ -89,5 +89,9 @@ func configDefault(config ...Config) Config { cfg.Bucket = ConfigDefault.Bucket } + if cfg.MaxRetry < 1 { + cfg.MaxRetry = ConfigDefault.MaxRetry + } + return cfg } From 603305cf39884a69df7b3eed3e7f3fd84ccc9da7 Mon Sep 17 00:00:00 2001 From: RW Date: Thu, 14 Nov 2024 15:11:21 +0100 Subject: [PATCH 3/3] Update minio/README.md --- minio/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/minio/README.md b/minio/README.md index ec23a51c..9c291f2d 100644 --- a/minio/README.md +++ b/minio/README.md @@ -95,8 +95,8 @@ type Config struct { 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 + // Optional. Default is 10, same as the MinIO client. + MaxRetry int // Credentials Minio access key and Minio secret key. // Need to be defined