Remove storage timeouts (#928)

* remove storage timeouts

* fix tests
This commit is contained in:
marpio
2018-11-16 22:00:08 +01:00
committed by Manu Gupta
parent 3061da5ee2
commit 4785e9c2b3
20 changed files with 32 additions and 103 deletions
+6 -5
View File
@@ -3,6 +3,7 @@ package actions
import (
"context"
"fmt"
"time"
"github.com/gomods/athens/pkg/config"
"github.com/gomods/athens/pkg/errors"
@@ -17,7 +18,7 @@ import (
)
// GetStorage returns storage backend based on env configuration
func GetStorage(storageType string, storageConfig *config.StorageConfig) (storage.Backend, error) {
func GetStorage(storageType string, storageConfig *config.StorageConfig, timeout time.Duration) (storage.Backend, error) {
const op errors.Op = "actions.GetStorage"
switch storageType {
case "memory":
@@ -26,7 +27,7 @@ func GetStorage(storageType string, storageConfig *config.StorageConfig) (storag
if storageConfig.Mongo == nil {
return nil, errors.E(op, "Invalid Mongo Storage Configuration")
}
return mongo.NewStorage(storageConfig.Mongo)
return mongo.NewStorage(storageConfig.Mongo, timeout)
case "disk":
if storageConfig.Disk == nil {
return nil, errors.E(op, "Invalid Disk Storage Configuration")
@@ -42,17 +43,17 @@ func GetStorage(storageType string, storageConfig *config.StorageConfig) (storag
if storageConfig.Minio == nil {
return nil, errors.E(op, "Invalid Minio Storage Configuration")
}
return minio.NewStorage(storageConfig.Minio)
return minio.NewStorage(storageConfig.Minio, timeout)
case "gcp":
if storageConfig.GCP == nil {
return nil, errors.E(op, "Invalid GCP Storage Configuration")
}
return gcp.New(context.Background(), storageConfig.GCP)
return gcp.New(context.Background(), storageConfig.GCP, timeout)
case "s3":
if storageConfig.S3 == nil {
return nil, errors.E(op, "Invalid S3 Storage Configuration")
}
return s3.New(storageConfig.S3)
return s3.New(storageConfig.S3, timeout)
default:
return nil, fmt.Errorf("storage type %s is unknown", storageType)
}