milvus/internal/indexnode/chunk_mgr_factory.go
cai.zhang c924f73105
Refactor for IndexCoord to support cloud (#18643)
Co-authored-by: Zach41 <zongmei.zhang@zilliz.com>
Signed-off-by: cai.zhang <cai.zhang@zilliz.com>

Signed-off-by: cai.zhang <cai.zhang@zilliz.com>
Co-authored-by: Zach41 <zongmei.zhang@zilliz.com>
2022-08-25 15:48:54 +08:00

46 lines
1.2 KiB
Go

package indexnode
import (
"context"
"fmt"
"sync"
"github.com/milvus-io/milvus/internal/proto/indexpb"
"github.com/milvus-io/milvus/internal/storage"
)
type StorageFactory interface {
NewChunkManager(ctx context.Context, config *indexpb.StorageConfig) (storage.ChunkManager, error)
}
type chunkMgr struct {
cached sync.Map
}
func (m *chunkMgr) NewChunkManager(ctx context.Context, config *indexpb.StorageConfig) (storage.ChunkManager, error) {
//key := m.cacheKey(bucket, storageAccessKey)
//if v, ok := m.cached.Load(key); ok {
// return v.(storage.ChunkManager), nil
//}
opts := []storage.Option{
storage.Address(config.Address),
storage.AccessKeyID(config.AccessKeyID),
storage.SecretAccessKeyID(config.SecretAccessKey),
storage.UseSSL(config.UseSSL),
storage.BucketName(config.BucketName),
storage.UseIAM(config.UseIAM),
storage.IAMEndpoint(config.IAMEndpoint),
}
factory := storage.NewChunkManagerFactory("local", "minio", opts...)
mgr, err := factory.NewVectorStorageChunkManager(ctx)
if err != nil {
return nil, err
}
//v, _ := m.cached.LoadOrStore(key, mgr)
return mgr, nil
}
func (m *chunkMgr) cacheKey(bucket, storageAccessKey string) string {
return fmt.Sprintf("%s/%s", bucket, storageAccessKey)
}