milvus/internal/storage/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

67 lines
2.2 KiB
Go

package storage
import (
"context"
"github.com/cockroachdb/errors"
"github.com/milvus-io/milvus/pkg/util/paramtable"
)
type ChunkManagerFactory struct {
persistentStorage string
config *config
}
func NewChunkManagerFactoryWithParam(params *paramtable.ComponentParam) *ChunkManagerFactory {
if params.CommonCfg.StorageType.GetValue() == "local" {
return NewChunkManagerFactory("local", RootPath(params.LocalStorageCfg.Path.GetValue()))
}
return NewChunkManagerFactory(params.CommonCfg.StorageType.GetValue(),
RootPath(params.MinioCfg.RootPath.GetValue()),
Address(params.MinioCfg.Address.GetValue()),
AccessKeyID(params.MinioCfg.AccessKeyID.GetValue()),
SecretAccessKeyID(params.MinioCfg.SecretAccessKey.GetValue()),
UseSSL(params.MinioCfg.UseSSL.GetAsBool()),
SslCACert(params.MinioCfg.SslCACert.GetValue()),
BucketName(params.MinioCfg.BucketName.GetValue()),
UseIAM(params.MinioCfg.UseIAM.GetAsBool()),
CloudProvider(params.MinioCfg.CloudProvider.GetValue()),
IAMEndpoint(params.MinioCfg.IAMEndpoint.GetValue()),
UseVirtualHost(params.MinioCfg.UseVirtualHost.GetAsBool()),
Region(params.MinioCfg.Region.GetValue()),
RequestTimeout(params.MinioCfg.RequestTimeoutMs.GetAsInt64()),
CreateBucket(true),
GcpCredentialJSON(params.MinioCfg.GcpCredentialJSON.GetValue()))
}
func NewChunkManagerFactory(persistentStorage string, opts ...Option) *ChunkManagerFactory {
c := newDefaultConfig()
for _, opt := range opts {
opt(c)
}
return &ChunkManagerFactory{
persistentStorage: persistentStorage,
config: c,
}
}
func (f *ChunkManagerFactory) newChunkManager(ctx context.Context, engine string) (ChunkManager, error) {
switch engine {
case "local":
return NewLocalChunkManager(RootPath(f.config.rootPath)), nil
case "remote", "minio", "opendal":
return NewRemoteChunkManager(ctx, f.config)
default:
return nil, errors.New("no chunk manager implemented with engine: " + engine)
}
}
func (f *ChunkManagerFactory) NewPersistentStorageChunkManager(ctx context.Context) (ChunkManager, error) {
return f.newChunkManager(ctx, f.persistentStorage)
}
type Factory interface {
NewPersistentStorageChunkManager(ctx context.Context) (ChunkManager, error)
}