milvus/internal/indexnode/chunk_mgr_factory.go
Rijin-N a05a37a583
enhance: GCS native support (GCS implemented using Google Cloud Storage libraries) (#36214)
Native support for Google cloud storage using the Google Cloud Storage
libraries. Authentication is performed using GCS service account
credentials JSON.

Currently, Milvus supports Google Cloud Storage using S3-compatible APIs
via the AWS SDK. This approach has the following limitations:

1. Overhead: Translating requests between S3-compatible APIs and GCS can
introduce additional overhead.
2. Compatibility Limitations: Some features of the original S3 API may
not fully translate or work as expected with GCS.

To address these limitations, This enhancement is needed.

Related Issue: #36212
2024-09-30 13:23:32 +08:00

50 lines
1.7 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.SslCACert(config.GetSslCACert()),
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),
storage.GcpCredentialJSON(config.GetGcpCredentialJSON()),
)
return chunkManagerFactory.NewPersistentStorageChunkManager(ctx)
}
func (m *chunkMgrFactory) cacheKey(storageType, bucket, address string) string {
return fmt.Sprintf("%s/%s/%s", storageType, bucket, address)
}