Refactor Milvus connection initialization
This commit is contained in:
@@ -2,8 +2,8 @@ package models
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/milvus-io/milvus-sdk-go/v2/client"
|
"github.com/milvus-io/milvus-sdk-go/v2/client"
|
||||||
)
|
)
|
||||||
@@ -20,9 +20,9 @@ func (m *MilvusConnection) Init() (err error) {
|
|||||||
log.Println("Milvus connection init")
|
log.Println("Milvus connection init")
|
||||||
host := Viper.Get("milvus.host").(string)
|
host := Viper.Get("milvus.host").(string)
|
||||||
port := Viper.Get("milvus.port").(int)
|
port := Viper.Get("milvus.port").(int)
|
||||||
address_of_milvus := host + ":" + strconv.Itoa(port)
|
address := fmt.Sprintf("%s:%d", host, port)
|
||||||
log.Println("Milvus address:", address_of_milvus)
|
log.Println("Milvus address:", address)
|
||||||
m.Client, err = client.NewGrpcClient(context.Background(), address_of_milvus)
|
m.Client, err = client.NewGrpcClient(context.Background(), address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Milvus connection failed:", err)
|
log.Println("Milvus connection failed:", err)
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user