mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-04 04:49:08 +08:00
a8a074162f
Signed-off-by: longjiquan <jiquan.long@zilliz.com> Signed-off-by: longjiquan <jiquan.long@zilliz.com>
30 lines
798 B
Go
30 lines
798 B
Go
package backend
|
|
|
|
import (
|
|
"github.com/milvus-io/milvus/cmd/tools/migration/configs"
|
|
"github.com/milvus-io/milvus/internal/kv"
|
|
etcdkv "github.com/milvus-io/milvus/internal/kv/etcd"
|
|
"github.com/milvus-io/milvus/internal/util/etcd"
|
|
clientv3 "go.etcd.io/etcd/client/v3"
|
|
)
|
|
|
|
type etcdBasedBackend struct {
|
|
cfg *configs.MilvusConfig
|
|
txn kv.MetaKv
|
|
etcdCli *clientv3.Client
|
|
}
|
|
|
|
func (b etcdBasedBackend) CleanWithPrefix(prefix string) error {
|
|
return b.txn.RemoveWithPrefix(prefix)
|
|
}
|
|
|
|
func newEtcdBasedBackend(cfg *configs.MilvusConfig) (*etcdBasedBackend, error) {
|
|
etcdCli, err := etcd.GetEtcdClient(cfg.EtcdCfg)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
txn := etcdkv.NewEtcdKV(etcdCli, cfg.EtcdCfg.MetaRootPath)
|
|
b := &etcdBasedBackend{cfg: cfg, etcdCli: etcdCli, txn: txn}
|
|
return b, nil
|
|
}
|