Merge pull request #1027 from restic/s3-set-retry

s3: Allow setting the number of retries for minio-go
This commit is contained in:
Alexander Neumann 2017-06-17 10:34:36 +02:00
commit 82b21cdf4a
2 changed files with 5 additions and 0 deletions

View file

@ -20,6 +20,7 @@ type Config struct {
Layout string `option:"layout" help:"use this backend layout (default: auto-detect)"` Layout string `option:"layout" help:"use this backend layout (default: auto-detect)"`
Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"` Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"`
MaxRetries uint `option:"retries" help:"set the number of retries attempted"`
} }
// NewConfig returns a new Config with the default values filled in. // NewConfig returns a new Config with the default values filled in.

View file

@ -39,6 +39,10 @@ const defaultLayout = "default"
func Open(cfg Config) (restic.Backend, error) { func Open(cfg Config) (restic.Backend, error) {
debug.Log("open, config %#v", cfg) debug.Log("open, config %#v", cfg)
if cfg.MaxRetries > 0 {
minio.MaxRetry = int(cfg.MaxRetries)
}
client, err := minio.New(cfg.Endpoint, cfg.KeyID, cfg.Secret, !cfg.UseHTTP) client, err := minio.New(cfg.Endpoint, cfg.KeyID, cfg.Secret, !cfg.UseHTTP)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "minio.New") return nil, errors.Wrap(err, "minio.New")