共用配置文件导入
This commit is contained in:
@@ -18,12 +18,11 @@ func (m *MilvusConnection) GetClient() client.Client {
|
||||
|
||||
func (m *MilvusConnection) Init() (err error) {
|
||||
log.Println("Milvus connection init")
|
||||
host := Viper.Get("milvus.host").(string)
|
||||
port := Viper.Get("milvus.port").(int)
|
||||
m.Client, err = client.NewGrpcClient(
|
||||
context.Background(),
|
||||
fmt.Sprintf("%s:%d", host, port),
|
||||
)
|
||||
m.Client, err = client.NewGrpcClient(context.Background(), fmt.Sprintf(
|
||||
"%s:%d",
|
||||
config.GetString("milvus.host"),
|
||||
config.GetInt("milvus.port"),
|
||||
))
|
||||
if err != nil {
|
||||
log.Println("Milvus connection failed:", err)
|
||||
return
|
||||
@@ -31,16 +30,3 @@ func (m *MilvusConnection) Init() (err error) {
|
||||
log.Println("Milvus connection success")
|
||||
return
|
||||
}
|
||||
|
||||
func (m *MilvusConnection) GetCollection(collection_name string) (collection *client.Client, err error) {
|
||||
if m.Client == nil {
|
||||
m.Init()
|
||||
}
|
||||
err = m.Client.LoadCollection(context.Background(), collection_name, false)
|
||||
if err != nil {
|
||||
log.Println("Milvus load collection failed:", err)
|
||||
return
|
||||
}
|
||||
collection = &m.Client
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user