mirror of https://github.com/milvus-io/milvus.git
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package storage
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
S3Driver "github.com/zilliztech/milvus-distributed/internal/storage/internal/S3"
|
|
minIODriver "github.com/zilliztech/milvus-distributed/internal/storage/internal/minio"
|
|
tikvDriver "github.com/zilliztech/milvus-distributed/internal/storage/internal/tikv"
|
|
"github.com/zilliztech/milvus-distributed/internal/storage/type"
|
|
)
|
|
|
|
func NewStore(ctx context.Context, driver storagetype.DriverType) (storagetype.Store, error) {
|
|
var err error
|
|
var store storagetype.Store
|
|
switch driver{
|
|
case storagetype.TIKVDriver:
|
|
store, err = tikvDriver.NewTikvStore(ctx)
|
|
if err != nil {
|
|
panic(err.Error())
|
|
}
|
|
return store, nil
|
|
case storagetype.MinIODriver:
|
|
store, err = minIODriver.NewMinioDriver(ctx)
|
|
if err != nil {
|
|
//panic(err.Error())
|
|
return nil, err
|
|
}
|
|
return store, nil
|
|
case storagetype.S3DRIVER:
|
|
store , err = S3Driver.NewS3Driver(ctx)
|
|
if err != nil {
|
|
//panic(err.Error())
|
|
return nil, err
|
|
}
|
|
return store, nil
|
|
}
|
|
return nil, errors.New("unsupported driver")
|
|
} |