mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-01 03:18:29 +08:00
6060dd7ea8
Signed-off-by: luzhang <luzhang@zilliz.com> Co-authored-by: luzhang <luzhang@zilliz.com>
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package indexnode
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/indexpb"
|
|
"github.com/milvus-io/milvus/internal/storage"
|
|
"github.com/milvus-io/milvus/pkg/util/typeutil"
|
|
)
|
|
|
|
type StorageFactory interface {
|
|
NewChunkManager(ctx context.Context, config *indexpb.StorageConfig) (storage.ChunkManager, error)
|
|
}
|
|
|
|
type chunkMgrFactory struct {
|
|
cached *typeutil.ConcurrentMap[string, storage.ChunkManager]
|
|
}
|
|
|
|
func NewChunkMgrFactory() *chunkMgrFactory {
|
|
return &chunkMgrFactory{
|
|
cached: typeutil.NewConcurrentMap[string, storage.ChunkManager](),
|
|
}
|
|
}
|
|
|
|
func (m *chunkMgrFactory) NewChunkManager(ctx context.Context, config *indexpb.StorageConfig) (storage.ChunkManager, error) {
|
|
chunkManagerFactory := storage.NewChunkManagerFactory(config.GetStorageType(),
|
|
storage.RootPath(config.GetRootPath()),
|
|
storage.Address(config.GetAddress()),
|
|
storage.AccessKeyID(config.GetAccessKeyID()),
|
|
storage.SecretAccessKeyID(config.GetSecretAccessKey()),
|
|
storage.UseSSL(config.GetUseSSL()),
|
|
storage.BucketName(config.GetBucketName()),
|
|
storage.UseIAM(config.GetUseIAM()),
|
|
storage.CloudProvider(config.GetCloudProvider()),
|
|
storage.IAMEndpoint(config.GetIAMEndpoint()),
|
|
storage.UseVirtualHost(config.GetUseVirtualHost()),
|
|
storage.RequestTimeout(config.GetRequestTimeoutMs()),
|
|
storage.Region(config.GetRegion()),
|
|
storage.CreateBucket(true),
|
|
)
|
|
return chunkManagerFactory.NewPersistentStorageChunkManager(ctx)
|
|
}
|
|
|
|
func (m *chunkMgrFactory) cacheKey(storageType, bucket, address string) string {
|
|
return fmt.Sprintf("%s/%s/%s", storageType, bucket, address)
|
|
}
|