initial commit
This commit is contained in:
20
data/storage/storage_factory.go
Normal file
20
data/storage/storage_factory.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func NewStorage(cfg *viper.Viper) (Storage, error) {
|
||||
storage_type := cfg.GetString("storage.db.type")
|
||||
|
||||
switch storage_type {
|
||||
case "mongodb":
|
||||
return NewMongoDBStorageFromConfig(cfg)
|
||||
case "mock":
|
||||
return NewMockStorage(), nil
|
||||
default:
|
||||
return nil, fmt.Errorf("storage type %v is not supported", storage_type)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user